mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
chore(scripts): update e2e prod build to work with ionic-app-scripts (#10083)
* chore(e2e): WIP to add files needed for app-scripts * chore(e2e): WIP one e2e test building but with errors * chore(e2e): move e2e.prod to working with app-scripts move shared functions into util, add support for debug flag when running e2e.prod / demos.prod which gets passed to app-scripts * chore(build): fix app-scripts build for all e2e and demos * chore(e2e): update ionic-angular import path * chore(build): update dev paths to work with prod * chore(e2e): get watch working with e2e prod * docs(scripts): update README for running e2e and demos closes #8411 closes #10023
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { NODE_MODULES_ROOT, PROJECT_ROOT, SRC_ROOT } from './constants';
|
||||
import { spawnSync } from 'child_process';
|
||||
import { NODE_MODULES_ROOT, SRC_ROOT } from './constants';
|
||||
import { src, dest } from 'gulp';
|
||||
import { join } from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { readdirSync, readFileSync, statSync, writeFileSync } from 'fs';
|
||||
import { rollup } from 'rollup';
|
||||
import { Replacer } from 'strip-function';
|
||||
import * as commonjs from 'rollup-plugin-commonjs';
|
||||
@ -32,7 +33,7 @@ export function mergeObjects(obj1: any, obj2: any ) {
|
||||
}
|
||||
|
||||
function getRootTsConfig(pathToReadFile): any {
|
||||
const json = fs.readFileSync(pathToReadFile);
|
||||
const json = readFileSync(pathToReadFile);
|
||||
|
||||
let tsConfig = JSON.parse(json.toString());
|
||||
return tsConfig;
|
||||
@ -53,7 +54,7 @@ export function createTempTsConfig(includeGlob: string[], target: string, module
|
||||
}
|
||||
config.include = includeGlob;
|
||||
let json = JSON.stringify(config, null, 2);
|
||||
fs.writeFileSync(pathToWriteFile, json);
|
||||
writeFileSync(pathToWriteFile, json);
|
||||
}
|
||||
|
||||
function removeDebugStatements() {
|
||||
@ -133,12 +134,12 @@ export function compileSass(destinationPath: string) {
|
||||
}
|
||||
|
||||
export function setSassIonicVersion(version: string) {
|
||||
fs.writeFileSync(join(SRC_ROOT, 'themes/version.scss'), `$ionic-version: "${version}";`);
|
||||
writeFileSync(join(SRC_ROOT, 'themes/version.scss'), `$ionic-version: "${version}";`);
|
||||
}
|
||||
|
||||
export function copyFile(srcPath: string, destPath: string) {
|
||||
const sourceData = fs.readFileSync(srcPath);
|
||||
fs.writeFileSync(destPath, sourceData);
|
||||
const sourceData = readFileSync(srcPath);
|
||||
writeFileSync(destPath, sourceData);
|
||||
}
|
||||
|
||||
export function runNgc(pathToConfigFile: string, done: Function) {
|
||||
@ -177,6 +178,38 @@ export function runWebpack(pathToWebpackConfig: string, done: Function) {
|
||||
});
|
||||
}
|
||||
|
||||
export function runAppScripts(folderInfo: any, sassConfigPath: string, appEntryPoint: string, distDir: string) {
|
||||
console.log('Running ionic-app-scripts build with', folderInfo.componentName, '/', folderInfo.componentTest);
|
||||
let tsConfig = distDir + 'tsconfig.json';
|
||||
let scriptArgs = [
|
||||
'build',
|
||||
'--prod',
|
||||
'--sass', sassConfigPath,
|
||||
'--appEntryPoint', appEntryPoint,
|
||||
'--srcDir', distDir,
|
||||
'--wwwDir', distDir,
|
||||
'--tsconfig', tsConfig
|
||||
];
|
||||
|
||||
const debug: boolean = argv.debug;
|
||||
if (debug) {
|
||||
scriptArgs.push('--debug');
|
||||
}
|
||||
|
||||
try {
|
||||
const scriptsCmd = spawnSync('ionic-app-scripts', scriptArgs);
|
||||
|
||||
if (scriptsCmd.status !== 0) {
|
||||
return Promise.reject(scriptsCmd.stderr.toString());
|
||||
}
|
||||
|
||||
console.log(scriptsCmd.output.toString());
|
||||
return Promise.resolve();
|
||||
} catch (ex) {
|
||||
return Promise.reject(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/** Resolves the path for a node package executable. */
|
||||
export function getBinaryPath(packageName: string, executable = packageName): string {
|
||||
return resolveBin.sync(packageName, {executable});
|
||||
@ -288,3 +321,10 @@ export function getFolderInfo() {
|
||||
componentTest: componentTest
|
||||
};
|
||||
}
|
||||
|
||||
export function getFolders(dir) {
|
||||
return readdirSync(dir)
|
||||
.filter(function(file) {
|
||||
return statSync(join(dir, file)).isDirectory();
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user