Skip to content

Commit cf788f0

Browse files
feat: support for solid/solidjs templates and migrations for 8.7 (#5796)
Co-authored-by: Igor Randjelovic <[email protected]>
1 parent f758f6c commit cf788f0

File tree

5 files changed

+57
-13
lines changed

5 files changed

+57
-13
lines changed

lib/commands/create-project.ts

+33-3
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ export class CreateProjectCommand implements ICommand {
4949
this.$options.ng ||
5050
this.$options.vue ||
5151
this.$options.react ||
52+
this.$options.solid ||
5253
this.$options.svelte ||
5354
this.$options.js) &&
5455
this.$options.template
5556
) {
5657
this.$errors.failWithHelp(
57-
"You cannot use a flavor option like --ng, --vue, --react, --svelte, --tsc and --js together with --template."
58+
"You cannot use a flavor option like --ng, --vue, --react, --solid, --svelte, --tsc and --js together with --template."
5859
);
5960
}
6061

@@ -70,8 +71,10 @@ export class CreateProjectCommand implements ICommand {
7071
(this.$options.vision && this.$options.react)
7172
) {
7273
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-react"];
73-
} else if (this.$options["vision-solid"]) {
74-
// note: we don't have solid templates or --solid
74+
} else if (
75+
this.$options["vision-solid"] ||
76+
(this.$options.vision && this.$options.solid)
77+
) {
7578
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-solid"];
7679
} else if (
7780
this.$options["vision-svelte"] ||
@@ -98,6 +101,8 @@ export class CreateProjectCommand implements ICommand {
98101
selectedTemplate = constants.ANGULAR_NAME;
99102
} else if (this.$options.vue || this.$options.vuejs) {
100103
selectedTemplate = constants.VUE_NAME;
104+
} else if (this.$options.solid) {
105+
selectedTemplate = constants.SOLID_NAME;
101106
} else if (this.$options.react) {
102107
selectedTemplate = constants.REACT_NAME;
103108
} else if (this.$options.svelte) {
@@ -170,6 +175,10 @@ export class CreateProjectCommand implements ICommand {
170175
key: constants.VueFlavorName,
171176
description: "Learn more at https://nativescript.org/vue",
172177
},
178+
{
179+
key: constants.SolidFlavorName,
180+
description: "Learn more at https://www.solidjs.com",
181+
},
173182
{
174183
key: constants.SvelteFlavorName,
175184
description: "Learn more at https://svelte-native.technology",
@@ -222,6 +231,10 @@ can skip this prompt next time using the --template option, or the --ng, --react
222231
selectedFlavorTemplates.push(...this.getVueTemplates());
223232
break;
224233
}
234+
case constants.SolidFlavorName: {
235+
selectedFlavorTemplates.push(...this.getSolidTemplates());
236+
break;
237+
}
225238
case constants.SvelteFlavorName: {
226239
selectedFlavorTemplates.push(...this.getSvelteTemplates());
227240
break;
@@ -346,6 +359,23 @@ can skip this prompt next time using the --template option, or the --ng, --react
346359
return templates;
347360
}
348361

362+
private getSolidTemplates() {
363+
const templates = [
364+
{
365+
key: CreateProjectCommand.HelloWorldTemplateKey,
366+
value: constants.RESERVED_TEMPLATE_NAMES.solid,
367+
description: CreateProjectCommand.HelloWorldTemplateDescription,
368+
},
369+
{
370+
key: CreateProjectCommand.BlankVisionTemplateKey,
371+
value: "@nativescript/template-blank-solid-vision",
372+
description: CreateProjectCommand.BlankVisionTemplateDescription,
373+
},
374+
];
375+
376+
return templates;
377+
}
378+
349379
private getSvelteTemplates() {
350380
const templates = [
351381
{

lib/constants.ts

+5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ export const RESERVED_TEMPLATE_NAMES: IStringDictionary = {
144144
angular: "@nativescript/template-hello-world-ng",
145145
react: "@nativescript/template-blank-react",
146146
reactjs: "@nativescript/template-blank-react",
147+
solid: "@nativescript/template-blank-solid",
148+
solidjs: "@nativescript/template-blank-solid",
147149
svelte: "@nativescript/template-blank-svelte",
148150
// vision templates
149151
vision: "@nativescript/template-hello-world-ts-vision",
@@ -184,10 +186,12 @@ export const ANGULAR_NAME = "angular";
184186
export const JAVASCRIPT_NAME = "javascript";
185187
export const TYPESCRIPT_NAME = "typescript";
186188
export const REACT_NAME = "react";
189+
export const SOLID_NAME = "solid";
187190
export const SVELTE_NAME = "svelte";
188191
export const NgFlavorName = "Angular";
189192
export const VueFlavorName = "Vue.js";
190193
export const ReactFlavorName = "React";
194+
export const SolidFlavorName = "Solid";
191195
export const SvelteFlavorName = "Svelte";
192196
export const TsFlavorName = "Plain TypeScript";
193197
export const JsFlavorName = "Plain JavaScript";
@@ -197,6 +201,7 @@ export class ProjectTypes {
197201
public static TsFlavorName = "Pure TypeScript";
198202
public static JsFlavorName = "Pure JavaScript";
199203
public static ReactFlavorName = "React";
204+
public static SolidFlavorName = "Solid";
200205
public static SvelteFlavorName = "Svelte";
201206
}
202207
export const BUILD_OUTPUT_EVENT_NAME = "buildOutput";

lib/controllers/migrate-controller.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class MigrateController
121121
{
122122
packageName: "@nativescript/core",
123123
minVersion: "6.5.0",
124-
desiredVersion: "~8.5.0",
124+
desiredVersion: "~8.7.0",
125125
shouldAddIfMissing: true,
126126
},
127127
{
@@ -131,7 +131,7 @@ export class MigrateController
131131
{
132132
packageName: "@nativescript/types",
133133
minVersion: "7.0.0",
134-
desiredVersion: "~8.5.0",
134+
desiredVersion: "~8.7.0",
135135
isDev: true,
136136
},
137137
{
@@ -190,7 +190,7 @@ export class MigrateController
190190
{
191191
packageName: "@nativescript/angular",
192192
minVersion: "10.0.0",
193-
desiredVersion: "^16.0.0",
193+
desiredVersion: "^17.0.0",
194194
async shouldMigrateAction(
195195
dependency: IMigrationDependency,
196196
projectData: IProjectData,
@@ -262,7 +262,7 @@ export class MigrateController
262262
packageName: "typescript",
263263
isDev: true,
264264
minVersion: "3.7.0",
265-
desiredVersion: "~4.8.4",
265+
desiredVersion: "~5.4.0",
266266
},
267267
{
268268
packageName: "node-sass",
@@ -274,7 +274,7 @@ export class MigrateController
274274
{
275275
packageName: "sass",
276276
minVersion: "0.0.0", // ignore
277-
desiredVersion: "~1.49.9",
277+
desiredVersion: "^1.49.9",
278278
isDev: true,
279279
// shouldRemove: true,
280280
},
@@ -295,13 +295,13 @@ export class MigrateController
295295
{
296296
packageName: "@nativescript/ios",
297297
minVersion: "6.5.3",
298-
desiredVersion: "~8.5.0",
298+
desiredVersion: "~8.7.0",
299299
isDev: true,
300300
},
301301
{
302302
packageName: "@nativescript/android",
303303
minVersion: "7.0.0",
304-
desiredVersion: "~8.5.0",
304+
desiredVersion: "~8.7.0",
305305
isDev: true,
306306
},
307307
];
@@ -1235,14 +1235,14 @@ export class MigrateController
12351235

12361236
// update
12371237
configContents.compilerOptions = configContents.compilerOptions || {};
1238-
configContents.compilerOptions.target = "es2017";
1238+
configContents.compilerOptions.target = "es2020";
12391239
configContents.compilerOptions.module = "esnext";
12401240
configContents.compilerOptions.moduleResolution = "node";
12411241
configContents.compilerOptions.experimentalDecorators = true;
12421242
configContents.compilerOptions.removeComments = false;
12431243

12441244
configContents.compilerOptions.lib = [
1245-
...new Set([...(configContents.compilerOptions.lib || []), "es2017"]),
1245+
...new Set([...(configContents.compilerOptions.lib || []), "ESNext"]),
12461246
];
12471247

12481248
if (isAngular) {
@@ -1310,7 +1310,7 @@ export class MigrateController
13101310

13111311
private async migrateNativeScriptAngular(): Promise<IMigrationDependency[]> {
13121312
const minVersion = "10.0.0";
1313-
const desiredVersion = "~16.2.0";
1313+
const desiredVersion = "~17.3.0";
13141314

13151315
const dependencies: IMigrationDependency[] = [
13161316
{

lib/declarations.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ interface IOptions
673673
ng: boolean;
674674
angular: boolean;
675675
react: boolean;
676+
solid: boolean;
676677
svelte: boolean;
677678
vue: boolean;
678679
vuejs: boolean;

test/project-commands.ts

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ const expectedFlavorChoices = [
3232
"Learn more at https://github.com/shirakaba/react-nativescript",
3333
},
3434
{ key: "Vue.js", description: "Learn more at https://nativescript.org/vue" },
35+
{
36+
key: "Solid",
37+
description: "Learn more at https://www.solidjs.com",
38+
},
3539
{
3640
key: "Svelte",
3741
description: "Learn more at https://svelte-native.technology",
@@ -111,6 +115,10 @@ const expectedTemplateChoices: Record<string, any[]> = {
111115
templateChoices.helloWorld,
112116
templateChoices.vision,
113117
],
118+
// [constants.SolidFlavorName]: [
119+
// templateChoices.helloWorld,
120+
// templateChoices.vision,
121+
// ],
114122
};
115123

116124
class ProjectServiceMock implements IProjectService {

0 commit comments

Comments
 (0)