Skip to content

Commit 2d8494e

Browse files
committed
fix: migration for demo executors and workspace scripts
1 parent b0b2651 commit 2d8494e

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

packages/plugin-tools/src/migrations/update-5-5-0/update-5-5-0.ts

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,40 @@ export default async function (tree: Tree) {
5555
'@nativescript/ios': '~8.8.0',
5656
},
5757
});
58-
const angularDemoProject = 'apps/demo-angular/project.json';
59-
if (tree.exists(angularDemoProject)) {
60-
updateJson(tree, angularDemoProject, (json) => {
61-
if (json.targets?.build?.options) {
62-
// ensure migrations to run against it
63-
json.targets.build.options.tsConfig = 'apps/demo-angular/tsconfig.json';
64-
}
65-
return json;
66-
});
58+
// update demo project configs
59+
const flavors = ['', 'angular', 'react', 'svelte', 'vue'];
60+
for (const flavor of flavors) {
61+
const projectBase = `apps/demo${flavor ? '-' + flavor : ''}`;
62+
const projectConfigPath = `${projectBase}/project.json`;
63+
if (tree.exists(projectConfigPath)) {
64+
updateJson(tree, projectConfigPath, (json) => {
65+
delete json.targets.ios;
66+
delete json.targets.android;
67+
json.targets.debug = {
68+
executor: '@nativescript/nx:debug',
69+
options: {
70+
noHmr: true,
71+
uglify: false,
72+
release: false,
73+
forDevice: false,
74+
prepare: false,
75+
},
76+
};
77+
json.targets.clean = {
78+
executor: '@nativescript/nx:clean',
79+
options: {},
80+
};
81+
82+
if (json.targets?.build?.options) {
83+
json.targets.build.options.tsConfig = `${projectBase}/tsconfig.json`;
84+
}
85+
return json;
86+
});
87+
}
6788
}
89+
// update workspace scripts
90+
fixWorkspaceScripts(tree);
91+
6892
updateJson(tree, 'nx.json', (json) => {
6993
json.release = {
7094
releaseTagPattern: '{version}-{projectName}',
@@ -123,6 +147,20 @@ export default async function (tree: Tree) {
123147
console.log(`\n`);
124148
}
125149

150+
function fixWorkspaceScripts(tree: Tree) {
151+
let workspaceScripts = tree.read('tools/workspace-scripts.js', 'utf-8');
152+
workspaceScripts = workspaceScripts.replace(`nx run demo:clean`, 'nx clean demo');
153+
workspaceScripts = workspaceScripts.replace(`nx run demo:ios`, 'nx debug demo ios');
154+
workspaceScripts = workspaceScripts.replace(`nx run demo:android`, 'nx debug demo android');
155+
const flavors = ['angular', 'react', 'svelte', 'vue'];
156+
for (const flavor of flavors) {
157+
workspaceScripts = workspaceScripts.replace(`nx run demo-${flavor}:clean`, `nx clean demo-${flavor}`);
158+
workspaceScripts = workspaceScripts.replace(`nx run demo-${flavor}:ios`, `nx debug demo-${flavor} ios`);
159+
workspaceScripts = workspaceScripts.replace(`nx run demo-${flavor}:android`, `nx debug demo-${flavor} android`);
160+
}
161+
tree.write('tools/workspace-scripts.js', workspaceScripts);
162+
}
163+
126164
function updateDependencies(tree: Tree) {
127165
updateJson(tree, 'package.json', (json) => {
128166
if (json.devDependencies['@angular/core']) {

0 commit comments

Comments
 (0)