Skip to content

Commit 8fbc23f

Browse files
committed
feat(create): vision flags
1 parent bc72497 commit 8fbc23f

File tree

5 files changed

+84
-13
lines changed

5 files changed

+84
-13
lines changed

lib/commands/create-project.ts

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export class CreateProjectCommand implements ICommand {
1515
private static BlankTemplateDescription = "A blank app";
1616
private static BlankTsTemplateKey = "Blank Typescript";
1717
private static BlankTsTemplateDescription = "A blank typescript app";
18+
private static BlankVisionTemplateKey = "visionOS";
19+
private static BlankVisionTemplateDescription = "A visionOS app";
1820
private static HelloWorldTemplateKey = "Hello World";
1921
private static HelloWorldTemplateDescription = "A Hello World app";
2022
private static DrawerTemplateKey = "SideDrawer";
@@ -72,6 +74,16 @@ export class CreateProjectCommand implements ICommand {
7274
selectedTemplate = constants.REACT_NAME;
7375
} else if (this.$options.svelte) {
7476
selectedTemplate = constants.SVELTE_NAME;
77+
} else if (this.$options["vision-ng"]) {
78+
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-ng"];
79+
} else if (this.$options["vision-react"]) {
80+
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-react"];
81+
} else if (this.$options["vision-solid"]) {
82+
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-solid"];
83+
} else if (this.$options["vision-svelte"]) {
84+
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-svelte"];
85+
} else if (this.$options["vision-vue"]) {
86+
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-vue"];
7587
} else {
7688
selectedTemplate = this.$options.template;
7789
}
@@ -262,6 +274,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
262274
value: "@nativescript/template-tab-navigation-ts",
263275
description: CreateProjectCommand.TabsTemplateDescription,
264276
},
277+
{
278+
key: CreateProjectCommand.BlankVisionTemplateKey,
279+
value: "@nativescript/template-hello-world-ts-vision",
280+
description: CreateProjectCommand.BlankVisionTemplateDescription,
281+
},
265282
];
266283

267284
return templates;
@@ -284,6 +301,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
284301
value: "@nativescript/template-tab-navigation-ng",
285302
description: CreateProjectCommand.TabsTemplateDescription,
286303
},
304+
{
305+
key: CreateProjectCommand.BlankVisionTemplateKey,
306+
value: "@nativescript/template-hello-world-ng-vision",
307+
description: CreateProjectCommand.BlankVisionTemplateDescription,
308+
},
287309
];
288310

289311
return templates;
@@ -296,6 +318,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
296318
value: constants.RESERVED_TEMPLATE_NAMES.react,
297319
description: CreateProjectCommand.HelloWorldTemplateDescription,
298320
},
321+
{
322+
key: CreateProjectCommand.BlankVisionTemplateKey,
323+
value: "@nativescript/template-blank-react-vision",
324+
description: CreateProjectCommand.BlankVisionTemplateDescription,
325+
},
299326
];
300327

301328
return templates;
@@ -308,6 +335,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
308335
value: constants.RESERVED_TEMPLATE_NAMES.svelte,
309336
description: CreateProjectCommand.HelloWorldTemplateDescription,
310337
},
338+
{
339+
key: CreateProjectCommand.BlankVisionTemplateKey,
340+
value: "@nativescript/template-blank-svelte-vision",
341+
description: CreateProjectCommand.BlankVisionTemplateDescription,
342+
},
311343
];
312344

313345
return templates;
@@ -335,6 +367,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
335367
value: "@nativescript/template-tab-navigation-vue",
336368
description: CreateProjectCommand.TabsTemplateDescription,
337369
},
370+
{
371+
key: CreateProjectCommand.BlankVisionTemplateKey,
372+
value: "@nativescript/template-blank-vue-vision",
373+
description: CreateProjectCommand.BlankVisionTemplateDescription,
374+
},
338375
];
339376

340377
return templates;
@@ -346,6 +383,33 @@ can skip this prompt next time using the --template option, or the --ng, --react
346383

347384
const greyDollarSign = color.grey("$");
348385
this.$logger.clearScreen();
386+
let runDebugNotes: Array<string> = [];
387+
if (
388+
this.$options.vision ||
389+
this.$options["vision-ng"] ||
390+
this.$options["vision-react"] ||
391+
this.$options["vision-solid"] ||
392+
this.$options["vision-svelte"] ||
393+
this.$options["vision-vue"]
394+
) {
395+
runDebugNotes = [
396+
`Run the project on Vision Pro with:`,
397+
"",
398+
` ${greyDollarSign} ${color.green("ns run visionos --no-hmr")}`,
399+
];
400+
} else {
401+
runDebugNotes = [
402+
`Run the project on multiple devices:`,
403+
"",
404+
` ${greyDollarSign} ${color.green("ns run ios")}`,
405+
` ${greyDollarSign} ${color.green("ns run android")}`,
406+
"",
407+
"Debug the project with Chrome DevTools:",
408+
"",
409+
` ${greyDollarSign} ${color.green("ns debug ios")}`,
410+
` ${greyDollarSign} ${color.green("ns debug android")}`,
411+
];
412+
}
349413
this.$logger.info(
350414
[
351415
[
@@ -358,15 +422,7 @@ can skip this prompt next time using the --template option, or the --ng, --react
358422
`cd ${relativePath}`
359423
)} and then:`,
360424
"",
361-
`Run the project on multiple devices:`,
362-
"",
363-
` ${greyDollarSign} ${color.green("ns run ios")}`,
364-
` ${greyDollarSign} ${color.green("ns run android")}`,
365-
"",
366-
"Debug the project with Chrome DevTools:",
367-
"",
368-
` ${greyDollarSign} ${color.green("ns debug ios")}`,
369-
` ${greyDollarSign} ${color.green("ns debug android")}`,
425+
...runDebugNotes,
370426
``,
371427
`For more options consult the docs or run ${color.green("ns --help")}`,
372428
"",

lib/commands/run.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export class RunIosCommand implements ICommand {
121121
);
122122
}
123123

124-
console.log("this.platform.toLowerCase()", this.platform.toLowerCase());
125124
const result =
126125
(await this.runCommand.canExecute(args)) &&
127126
(await this.$platformValidationService.validateOptions(

lib/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,19 @@ export const RESERVED_TEMPLATE_NAMES: IStringDictionary = {
138138
default: "@nativescript/template-hello-world",
139139
javascript: "@nativescript/template-hello-world",
140140
tsc: "@nativescript/template-hello-world-ts",
141+
vision: "@nativescript/template-hello-world-ts-vision",
141142
vue: "@nativescript/template-blank-vue",
143+
"vision-vue": "@nativescript/template-blank-vue-vision",
142144
typescript: "@nativescript/template-hello-world-ts",
143145
ng: "@nativescript/template-hello-world-ng",
144146
angular: "@nativescript/template-hello-world-ng",
147+
"vision-ng": "@nativescript/template-hello-world-ng-vision",
145148
react: "@nativescript/template-blank-react",
149+
"vision-react": "@nativescript/template-blank-react-vision",
146150
reactjs: "@nativescript/template-blank-react",
151+
"vision-solid": "@nativescript/template-blank-solid-vision",
147152
svelte: "@nativescript/template-blank-svelte",
153+
"vision-svelte": "@nativescript/template-blank-svelte-vision",
148154
};
149155

150156
export const ANALYTICS_LOCAL_TEMPLATE_PREFIX = "localTemplate_";

lib/declarations.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,12 @@ interface IOptions
677677
vue: boolean;
678678
vuejs: boolean;
679679
js: boolean;
680+
vision: boolean;
681+
"vision-ng": boolean;
682+
"vision-react": boolean;
683+
"vision-solid": boolean;
684+
"vision-svelte": boolean;
685+
"vision-vue": boolean;
680686
javascript: boolean;
681687
androidTypings: boolean;
682688
production: boolean; //npm flag

lib/options.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ export class Options {
132132
vue: { type: OptionType.Boolean, hasSensitiveValue: false },
133133
vuejs: { type: OptionType.Boolean, hasSensitiveValue: false },
134134
svelte: { type: OptionType.Boolean, hasSensitiveValue: false },
135+
"vision-ng": { type: OptionType.Boolean, hasSensitiveValue: false },
136+
"vision-react": { type: OptionType.Boolean, hasSensitiveValue: false },
137+
"vision-solid": { type: OptionType.Boolean, hasSensitiveValue: false },
138+
"vision-svelte": { type: OptionType.Boolean, hasSensitiveValue: false },
139+
"vision-vue": { type: OptionType.Boolean, hasSensitiveValue: false },
135140
tsc: { type: OptionType.Boolean, hasSensitiveValue: false },
136141
ts: { type: OptionType.Boolean, hasSensitiveValue: false },
137142
typescript: { type: OptionType.Boolean, hasSensitiveValue: false },
@@ -422,9 +427,8 @@ export class Options {
422427
this.$settingsService.setSettings({
423428
profileDir: <string>this.argv.profileDir,
424429
});
425-
this.argv.profileDir = this.argv[
426-
"profile-dir"
427-
] = this.$settingsService.getProfileDir();
430+
this.argv.profileDir = this.argv["profile-dir"] =
431+
this.$settingsService.getProfileDir();
428432

429433
// if justlaunch is set, it takes precedence over the --watch flag and the default true value
430434
if (this.argv.justlaunch) {

0 commit comments

Comments
 (0)