Skip to content

Commit 6ef32ca

Browse files
committed
fix(): update app-scripts integration.
1 parent b0ea99a commit 6ef32ca

8 files changed

Lines changed: 28 additions & 27 deletions

File tree

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"lerna": "2.0.0-beta.34",
2+
"lerna": "2.0.0-beta.36",
33
"version": "independent",
44
"packages": [
55
"packages/*"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"coveralls": "^2.2.0",
2727
"eslint-config-ionic": "0.0.2",
2828
"jest-cli": "^17.0.3",
29-
"lerna": "2.0.0-beta.34",
29+
"lerna": "2.0.0-beta.36",
3030
"rollup": "^0.36.1",
3131
"rollup-plugin-commonjs": "^5.0.4",
3232
"rollup-plugin-json": "^2.0.2",

packages/cli-plugin-cordova/src/commands/emulate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class EmulateCommand extends Command {
127127
// using app-scripts and livereload is requested
128128
// Also remove commandName from the rawArgs passed
129129
tasks.next(`Starting app-scripts server`);
130-
await startAppScriptsServer(this.metadata, inputs, options);
130+
await startAppScriptsServer(this.env.project.directory, this.metadata, inputs, options);
131131
}
132132

133133
// ensure the content node was set back to its original

packages/cli-plugin-cordova/src/commands/resources.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,19 @@ export class ResourcesCommand extends Command {
205205
/**
206206
* Call the transform service and output images to appropriate destination
207207
*/
208-
let task = tasks.next(`Generating platform resources`);
208+
tasks.next(`Generating platform resources`);
209209
let count = 0;
210210

211211
const promiseList = imgResources.map((img, index): Promise<void> => {
212212
return transformResourceImage(img).then(() => {
213213
count += 1;
214-
task.updateMsg(`Generating platform resources: ${chalk.bold(`${count} / ${imgResources.length}`)} complete`);
214+
tasks.updateMsg(`Generating platform resources: ${chalk.bold(`${count} / ${imgResources.length}`)} complete`);
215215
});
216216
});
217217

218218
try {
219219
const generateImageResponses = await Promise.all(promiseList);
220-
task.updateMsg(`Generating platform resources: ${chalk.bold(`${imgResources.length} / ${imgResources.length}`)} complete`);
220+
tasks.updateMsg(`Generating platform resources: ${chalk.bold(`${imgResources.length} / ${imgResources.length}`)} complete`);
221221
this.env.log.debug(`${chalk.green('generateResourceImage')} completed - responses=${JSON.stringify(generateImageResponses, null, 2)}`);
222222
} catch (e) {
223223
throw e;

packages/cli-plugin-cordova/src/commands/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class RunCommand extends Command {
127127
// using app-scripts and livereload is requested
128128
// Also remove commandName from the rawArgs passed
129129
tasks.next(`Starting app-scripts server`);
130-
await startAppScriptsServer(this.metadata, inputs, options);
130+
await startAppScriptsServer(this.env.project.directory, this.metadata, inputs, options);
131131
}
132132

133133
// ensure the content node was set back to its original

packages/cli-plugin-cordova/src/lib/utils/cordova.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { writeConfigXmlContentSrc } from './configXmlUtils';
1+
import { writeConfigXmlContentSrc } from './configXmlUtils';
22
import {
33
CommandData,
44
CommandLineInputs,
55
CommandLineOptions,
66
normalizeOptionAliases,
77
minimistOptionsToArray,
8-
appScriptsServe,
9-
appScriptsBuild
108
} from '@ionic/cli-utils';
9+
import {
10+
generateContext,
11+
build
12+
} from '@ionic/app-scripts';
1113

1214
/**
1315
* Filter and gather arguments from command line to be passed to Cordova
@@ -40,7 +42,7 @@ export function filterArgumentsForCordova(metadata: CommandData, inputs: Command
4042
/**
4143
* Start the app scripts server for emulator or device
4244
*/
43-
export async function startAppScriptsServer(metadata: CommandData, inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
45+
export async function startAppScriptsServer(projectDirectory: string, metadata: CommandData, inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
4446
const results = normalizeOptionAliases(metadata, options);
4547
let args = minimistOptionsToArray(metadata, results);
4648

@@ -50,13 +52,17 @@ export async function startAppScriptsServer(metadata: CommandData, inputs: Comma
5052
'--nobrowser'
5153
]);
5254

53-
const serveSettings = await appScriptsServe(args);
54-
await writeConfigXmlContentSrc(process.cwd(), serveSettings.url);
55+
process.argv = process.argv.slice(0, 3).concat(args);
56+
const context = generateContext();
57+
const serverSettings = await build(context);
58+
await writeConfigXmlContentSrc(projectDirectory, serverSettings.url);
5559
}
5660

5761
export async function runAppScriptsBuild(metadata: CommandData, inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
5862
const results = normalizeOptionAliases(metadata, options);
5963
let args = minimistOptionsToArray(metadata, results);
6064

61-
await appScriptsBuild(args);
65+
process.argv = process.argv.slice(0, 3).concat(args);
66+
const context = generateContext();
67+
await build(context);
6268
}

packages/cli-plugin-core/src/commands/serve.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import {
44
Command,
55
CommandMetadata,
66
normalizeOptionAliases,
7-
minimistOptionsToArray,
8-
TaskChain
7+
minimistOptionsToArray
98
} from '@ionic/cli-utils';
10-
import * as appScripts from '@ionic/app-scripts';
9+
import {
10+
generateContext,
11+
serve
12+
} from '@ionic/app-scripts';
1113

1214
@CommandMetadata({
1315
name: 'serve',
@@ -87,18 +89,12 @@ import * as appScripts from '@ionic/app-scripts';
8789
export class ServeCommand extends Command {
8890
async run(inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
8991

90-
var tasks = new TaskChain();
91-
9292
const results = normalizeOptionAliases(this.metadata, options);
9393
const args = minimistOptionsToArray(this.metadata, results);
9494

95-
tasks.next(`Starting app-scripts server`);
96-
9795
// Update process args so that app scripts can just read current process args.
9896
process.argv = process.argv.slice(0, 3).concat(args);
99-
let response = await appScripts.build({});
100-
console.log(response);
101-
102-
tasks.end();
97+
const context = generateContext();
98+
await serve(context);
10399
}
104100
}

packages/ionic/src/ionic.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ export async function run(pargv: string[], env: { [k: string]: string }) {
6969
} else {
7070
console.error(err);
7171
}
72+
process.exit(exitCode);
7273
}
73-
74-
process.exit(exitCode);
7574
}
7675

7776
/**

0 commit comments

Comments
 (0)