Skip to content

Commit

Permalink
feat(core): update apps preset to also set up integrated style; do ad…
Browse files Browse the repository at this point in the history
…d ts plugin by default from react generators
  • Loading branch information
jaysoo committed Nov 13, 2024
1 parent e812720 commit 4f67272
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 23 deletions.
3 changes: 0 additions & 3 deletions packages/detox/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ export async function detoxApplicationGeneratorInternal(
) {
const jsInitTask = await jsInitGenerator(host, {
skipFormat: true,
addTsPlugin:
process.env.NX_ADD_PLUGINS !== 'false' &&
process.env.NX_ADD_TS_PLUGIN !== 'false',
});

const options = await normalizeOptions(host, schema);
Expand Down
4 changes: 1 addition & 3 deletions packages/expo/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export async function expoApplicationGeneratorInternal(
const jsInitTask = await jsInitGenerator(host, {
...schema,
skipFormat: true,
addTsPlugin:
process.env.NX_ADD_PLUGINS !== 'false' &&
process.env.NX_ADD_TS_PLUGIN !== 'false',
addTsPlugin: schema.useTsSolution,
});

const options = await normalizeOptions(host, schema);
Expand Down
2 changes: 2 additions & 0 deletions packages/expo/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface Schema {
e2eTestRunner: 'cypress' | 'playwright' | 'detox' | 'none'; // default is none
standaloneConfig?: boolean;
skipPackageJson?: boolean; // default is false
// Internal options
addPlugin?: boolean;
nxCloudToken?: string;
useTsSolution?: boolean;
}
4 changes: 1 addition & 3 deletions packages/next/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ export async function applicationGeneratorInternal(host: Tree, schema: Schema) {
js: options.js,
skipPackageJson: options.skipPackageJson,
skipFormat: true,
addTsPlugin:
process.env.NX_ADD_PLUGINS !== 'false' &&
process.env.NX_ADD_TS_PLUGIN !== 'false',
addTsPlugin: schema.useTsSolution,
});
tasks.push(jsInitTask);

Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export interface Schema {
skipPackageJson?: boolean;
appDir?: boolean;
src?: boolean;
// Internal options
rootProject?: boolean;
addPlugin?: boolean;
useTsSolution?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export async function reactNativeApplicationGeneratorInternal(
const jsInitTask = await jsInitGenerator(host, {
...schema,
skipFormat: true,
addTsPlugin:
process.env.NX_ADD_PLUGINS !== 'false' &&
process.env.NX_ADD_TS_PLUGIN !== 'false',
addTsPlugin: schema.useTsSolution,
});
tasks.push(jsInitTask);

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export interface Schema {
bundler: 'webpack' | 'vite'; // default is webpack
install: boolean; // default is true
skipPackageJson?: boolean; //default is false
// Internal options
addPlugin?: boolean;
nxCloudToken?: string;
useTsSolution?: boolean;
}
4 changes: 1 addition & 3 deletions packages/react/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ export async function applicationGeneratorInternal(
...schema,
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
skipFormat: true,
addTsPlugin:
process.env.NX_ADD_PLUGINS !== 'false' &&
process.env.NX_ADD_TS_PLUGIN !== 'false',
addTsPlugin: schema.useTsSolution,
});
tasks.push(jsInitTask);

Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ export interface Schema {
rootProject?: boolean;
bundler?: 'webpack' | 'vite' | 'rspack';
minimal?: boolean;
// Internal options
addPlugin?: boolean;
nxCloudToken?: string;
useTsSolution?: boolean;
}

export interface NormalizedSchema<T extends Schema = Schema> extends T {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/generators/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"enum": ["playwright", "cypress", "none"],
"description": "Test runner to use for end to end (E2E) tests.",
"x-prompt": "Which E2E test runner would you like to use?",
"default": "playwright"
"default": "none"
},
"tags": {
"type": "string",
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ export async function libraryGeneratorInternal(host: Tree, schema: Schema) {
const jsInitTask = await jsInitGenerator(host, {
...schema,
skipFormat: true,
addTsPlugin:
process.env.NX_ADD_PLUGINS !== 'false' &&
process.env.NX_ADD_TS_PLUGIN !== 'false',
});
tasks.push(jsInitTask);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ export async function remixApplicationGeneratorInternal(
}),
await jsInitGenerator(tree, {
skipFormat: true,
addTsPlugin:
process.env.NX_ADD_PLUGINS !== 'false' &&
process.env.NX_ADD_TS_PLUGIN !== 'false',
addTsPlugin: _options.useTsSolution,
}),
];

Expand Down
2 changes: 2 additions & 0 deletions packages/remix/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export interface NxRemixGeneratorSchema {
unitTestRunner?: 'vitest' | 'jest' | 'none';
e2eTestRunner?: 'cypress' | 'playwright' | 'none';
skipFormat?: boolean;
// Internal options
rootProject?: boolean;
addPlugin?: boolean;
nxCloudToken?: string;
useTsSolution?: boolean;
}
12 changes: 11 additions & 1 deletion packages/workspace/src/generators/preset/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ async function createPreset(tree: Tree, options: Schema) {
nxJson.useInferencePlugins !== false;

if (options.preset === Preset.Apps) {
return;
const { initGenerator } = require('@nx' + '/js');
return initGenerator(tree, {
formatter: options.formatter,
addTsPlugin: false,
addTsConfigBase: true,
});
} else if (options.preset === Preset.AngularMonorepo) {
const {
applicationGenerator: angularApplicationGenerator,
Expand Down Expand Up @@ -71,6 +76,7 @@ async function createPreset(tree: Tree, options: Schema) {
e2eTestRunner: options.e2eTestRunner ?? 'playwright',
addPlugin,
nxCloudToken: options.nxCloudToken,
useTsSolution: true,
});
} else if (options.preset === Preset.ReactStandalone) {
const { applicationGenerator: reactApplicationGenerator } = require('@nx' +
Expand Down Expand Up @@ -100,6 +106,7 @@ async function createPreset(tree: Tree, options: Schema) {
unitTestRunner: 'vitest',
addPlugin,
nxCloudToken: options.nxCloudToken,
useTsSolution: true,
});
} else if (options.preset === Preset.RemixStandalone) {
const { applicationGenerator: remixApplicationGenerator } = require('@nx' +
Expand Down Expand Up @@ -184,6 +191,7 @@ async function createPreset(tree: Tree, options: Schema) {
src: options.nextSrcDir,
e2eTestRunner: options.e2eTestRunner ?? 'playwright',
addPlugin,
useTsSolution: true,
});
} else if (options.preset === Preset.NextJsStandalone) {
const { applicationGenerator: nextApplicationGenerator } = require('@nx' +
Expand Down Expand Up @@ -246,6 +254,7 @@ async function createPreset(tree: Tree, options: Schema) {
addPlugin,
nxCloudToken: options.nxCloudToken,
bundler: options.bundler ?? 'webpack',
useTsSolution: true,
});
} else if (options.preset === Preset.Expo) {
const { expoApplicationGenerator } = require('@nx' + '/expo');
Expand All @@ -256,6 +265,7 @@ async function createPreset(tree: Tree, options: Schema) {
e2eTestRunner: options.e2eTestRunner ?? 'detox',
addPlugin,
nxCloudToken: options.nxCloudToken,
useTsSolution: true,
});
} else if (options.preset === Preset.TS) {
const { initGenerator } = require('@nx' + '/js');
Expand Down

0 comments on commit 4f67272

Please sign in to comment.