chore(testing): reduce create-workspace --preset=npm e2e time (#15239)
This commit is contained in:
parent
aaed63ba18
commit
3ef5406fb8
@ -12,6 +12,12 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"x-priority": "internal"
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [],
|
"required": [],
|
||||||
|
|||||||
@ -19,6 +19,12 @@
|
|||||||
"description": "Skip formatting files.",
|
"description": "Skip formatting files.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
@ -122,6 +122,12 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
|
"description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
@ -118,6 +118,12 @@
|
|||||||
"description": "Use a custom Express server for the Next.js application.",
|
"description": "Use a custom Express server for the Next.js application.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [],
|
"required": [],
|
||||||
|
|||||||
@ -30,6 +30,12 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Use JavaScript instead of TypeScript"
|
"description": "Use JavaScript instead of TypeScript"
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [],
|
"required": [],
|
||||||
|
|||||||
@ -146,6 +146,12 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
"x-deprecated": "Nx only supports standaloneConfig"
|
"x-deprecated": "Nx only supports standaloneConfig"
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name"],
|
"required": ["name"],
|
||||||
|
|||||||
@ -2,13 +2,11 @@ import {
|
|||||||
createNonNxProjectDirectory,
|
createNonNxProjectDirectory,
|
||||||
runCLI,
|
runCLI,
|
||||||
runCommand,
|
runCommand,
|
||||||
tmpProjPath,
|
|
||||||
updateFile,
|
updateFile,
|
||||||
getPackageManagerCommand,
|
getPackageManagerCommand,
|
||||||
getSelectedPackageManager,
|
getSelectedPackageManager,
|
||||||
getPublishedVersion,
|
getPublishedVersion,
|
||||||
} from '@nrwl/e2e/utils';
|
} from '@nrwl/e2e/utils';
|
||||||
import { Workspaces } from 'nx/src/config/workspaces';
|
|
||||||
|
|
||||||
describe('add-nx-to-monorepo', () => {
|
describe('add-nx-to-monorepo', () => {
|
||||||
const pmc = getPackageManagerCommand({
|
const pmc = getPackageManagerCommand({
|
||||||
|
|||||||
11
e2e/workspace-create-npm/jest.config.ts
Normal file
11
e2e/workspace-create-npm/jest.config.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
export default {
|
||||||
|
transform: {
|
||||||
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
|
},
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
|
maxWorkers: 1,
|
||||||
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
|
displayName: 'e2e-workspace-create-npm',
|
||||||
|
preset: '../../jest.preset.js',
|
||||||
|
};
|
||||||
11
e2e/workspace-create-npm/project.json
Normal file
11
e2e/workspace-create-npm/project.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "e2e-workspace-create-npm",
|
||||||
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||||
|
"sourceRoot": "e2e/workspace-create-npm",
|
||||||
|
"projectType": "application",
|
||||||
|
"targets": {
|
||||||
|
"e2e": {},
|
||||||
|
"run-e2e-tests": {}
|
||||||
|
},
|
||||||
|
"implicitDependencies": ["create-nx-workspace"]
|
||||||
|
}
|
||||||
@ -1,11 +1,14 @@
|
|||||||
|
import { forEach } from '@angular-devkit/schematics';
|
||||||
import {
|
import {
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
cleanupProject,
|
cleanupProject,
|
||||||
packageInstall,
|
packageInstall,
|
||||||
readJson,
|
readJson,
|
||||||
|
removeFile,
|
||||||
runCLI,
|
runCLI,
|
||||||
runCreateWorkspace,
|
runCreateWorkspace,
|
||||||
uniq,
|
uniq,
|
||||||
|
updateJson,
|
||||||
} from '@nrwl/e2e/utils';
|
} from '@nrwl/e2e/utils';
|
||||||
|
|
||||||
describe('create-nx-workspace --preset=npm', () => {
|
describe('create-nx-workspace --preset=npm', () => {
|
||||||
@ -25,7 +28,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const appName = uniq('my-app');
|
const appName = uniq('my-app');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/angular:app ${appName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/angular:app ${appName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
}, 1_000_000);
|
}, 1_000_000);
|
||||||
@ -35,7 +40,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/angular:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/angular:lib ${libName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -50,7 +57,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() =>
|
expect(() =>
|
||||||
runCLI(`generate @nrwl/workspace:library ${libName} --no-interactive`)
|
runCLI(
|
||||||
|
`generate @nrwl/workspace:library ${libName} --skipPackageJson --no-interactive`
|
||||||
|
)
|
||||||
).not.toThrowError();
|
).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -65,7 +74,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() =>
|
expect(() =>
|
||||||
runCLI(`generate @nrwl/js:library ${libName} --no-interactive`)
|
runCLI(
|
||||||
|
`generate @nrwl/js:library ${libName} --skipPackageJson --no-interactive`
|
||||||
|
)
|
||||||
).not.toThrowError();
|
).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -80,7 +91,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const appName = uniq('my-app');
|
const appName = uniq('my-app');
|
||||||
|
|
||||||
expect(() =>
|
expect(() =>
|
||||||
runCLI(`generate @nrwl/web:app ${appName} --no-interactive`)
|
runCLI(
|
||||||
|
`generate @nrwl/web:app ${appName} --skipPackageJson --no-interactive`
|
||||||
|
)
|
||||||
).not.toThrowError();
|
).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
});
|
});
|
||||||
@ -91,7 +104,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const appName = uniq('my-app');
|
const appName = uniq('my-app');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/react:app ${appName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/react:app ${appName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
});
|
});
|
||||||
@ -102,7 +117,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/react:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/react:lib ${libName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -117,7 +134,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const appName = uniq('my-app');
|
const appName = uniq('my-app');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/next:app ${appName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/next:app ${appName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
});
|
});
|
||||||
@ -128,7 +147,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/next:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/next:lib ${libName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -143,7 +164,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const appName = uniq('my-app');
|
const appName = uniq('my-app');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/react-native:app ${appName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/react-native:app ${appName} --install=false --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
});
|
});
|
||||||
@ -154,7 +177,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/react-native:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/react-native:lib ${libName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -169,7 +194,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const appName = uniq('my-app');
|
const appName = uniq('my-app');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/node:app ${appName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/node:app ${appName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
});
|
});
|
||||||
@ -180,7 +207,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/node:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/node:lib ${libName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -195,7 +224,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const appName = uniq('my-app');
|
const appName = uniq('my-app');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/nest:app ${appName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/nest:app ${appName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
});
|
});
|
||||||
@ -206,7 +237,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const libName = uniq('lib');
|
const libName = uniq('lib');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/nest:lib ${libName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/nest:lib ${libName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
const tsconfig = readJson(`tsconfig.base.json`);
|
const tsconfig = readJson(`tsconfig.base.json`);
|
||||||
@ -221,7 +254,9 @@ describe('create-nx-workspace --preset=npm', () => {
|
|||||||
const appName = uniq('my-app');
|
const appName = uniq('my-app');
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runCLI(`generate @nrwl/express:app ${appName} --no-interactive`);
|
runCLI(
|
||||||
|
`generate @nrwl/express:app ${appName} --skipPackageJson --no-interactive`
|
||||||
|
);
|
||||||
}).not.toThrowError();
|
}).not.toThrowError();
|
||||||
checkFilesExist('tsconfig.base.json');
|
checkFilesExist('tsconfig.base.json');
|
||||||
});
|
});
|
||||||
13
e2e/workspace-create-npm/tsconfig.json
Normal file
13
e2e/workspace-create-npm/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"types": ["node", "jest"]
|
||||||
|
},
|
||||||
|
"include": [],
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.spec.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
20
e2e/workspace-create-npm/tsconfig.spec.json
Normal file
20
e2e/workspace-create-npm/tsconfig.spec.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../../dist/out-tsc",
|
||||||
|
"module": "commonjs",
|
||||||
|
"types": ["jest", "node"]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"**/*.test.ts",
|
||||||
|
"**/*.spec.ts",
|
||||||
|
"**/*.spec.tsx",
|
||||||
|
"**/*.test.tsx",
|
||||||
|
"**/*.spec.js",
|
||||||
|
"**/*.test.js",
|
||||||
|
"**/*.spec.jsx",
|
||||||
|
"**/*.test.jsx",
|
||||||
|
"**/*.d.ts",
|
||||||
|
"jest.config.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -13,6 +13,7 @@ export async function detoxApplicationGenerator(host: Tree, schema: Schema) {
|
|||||||
const options = normalizeOptions(host, schema);
|
const options = normalizeOptions(host, schema);
|
||||||
|
|
||||||
const initTask = await detoxInitGenerator(host, {
|
const initTask = await detoxInitGenerator(host, {
|
||||||
|
...options,
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
});
|
});
|
||||||
createFiles(host, options);
|
createFiles(host, options);
|
||||||
|
|||||||
@ -9,6 +9,12 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"x-priority": "internal"
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": []
|
"required": []
|
||||||
|
|||||||
@ -59,12 +59,15 @@ export async function expoInitGenerator(host: Tree, schema: Schema) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
|
if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
|
||||||
const jestTask = await jestInitGenerator(host, {});
|
const jestTask = await jestInitGenerator(host, schema);
|
||||||
tasks.push(jestTask);
|
tasks.push(jestTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'detox') {
|
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'detox') {
|
||||||
const detoxTask = await detoxInitGenerator(host, { skipFormat: true });
|
const detoxTask = await detoxInitGenerator(host, {
|
||||||
|
...schema,
|
||||||
|
skipFormat: true,
|
||||||
|
});
|
||||||
tasks.push(detoxTask);
|
tasks.push(detoxTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export async function applicationGenerator(
|
|||||||
): Promise<GeneratorCallback> {
|
): Promise<GeneratorCallback> {
|
||||||
const options = normalizeOptions(tree, rawOptions);
|
const options = normalizeOptions(tree, rawOptions);
|
||||||
const initTask = await initGenerator(tree, {
|
const initTask = await initGenerator(tree, {
|
||||||
|
skipPackageJson: options.skipPackageJson,
|
||||||
unitTestRunner: options.unitTestRunner,
|
unitTestRunner: options.unitTestRunner,
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,14 +10,21 @@ export async function initGenerator(
|
|||||||
rawOptions: InitGeneratorOptions
|
rawOptions: InitGeneratorOptions
|
||||||
): Promise<GeneratorCallback> {
|
): Promise<GeneratorCallback> {
|
||||||
const options = normalizeOptions(rawOptions);
|
const options = normalizeOptions(rawOptions);
|
||||||
|
const tasks: GeneratorCallback[] = [];
|
||||||
|
|
||||||
const nodeInitTask = await nodeInitGenerator(tree, options);
|
const nodeInitTask = await nodeInitGenerator(tree, options);
|
||||||
|
tasks.push(nodeInitTask);
|
||||||
|
|
||||||
|
if (!options.skipPackageJson) {
|
||||||
const installPackagesTask = addDependencies(tree);
|
const installPackagesTask = addDependencies(tree);
|
||||||
|
tasks.push(installPackagesTask);
|
||||||
|
}
|
||||||
|
|
||||||
if (!options.skipFormat) {
|
if (!options.skipFormat) {
|
||||||
await formatFiles(tree);
|
await formatFiles(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
return runTasksInSerial(nodeInitTask, installPackagesTask);
|
return runTasksInSerial(...tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default initGenerator;
|
export default initGenerator;
|
||||||
|
|||||||
@ -3,4 +3,5 @@ import { UnitTestRunner } from '../utils';
|
|||||||
export interface InitGeneratorOptions {
|
export interface InitGeneratorOptions {
|
||||||
skipFormat?: boolean;
|
skipFormat?: boolean;
|
||||||
unitTestRunner?: UnitTestRunner;
|
unitTestRunner?: UnitTestRunner;
|
||||||
|
skipPackageJson?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,12 @@
|
|||||||
"description": "Skip formatting files.",
|
"description": "Skip formatting files.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
@ -29,6 +29,7 @@ export interface LibraryGeneratorOptions {
|
|||||||
unitTestRunner?: UnitTestRunner;
|
unitTestRunner?: UnitTestRunner;
|
||||||
standaloneConfig?: boolean;
|
standaloneConfig?: boolean;
|
||||||
setParserOptionsProject?: boolean;
|
setParserOptionsProject?: boolean;
|
||||||
|
skipPackageJson?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NormalizedOptions extends LibraryGeneratorOptions {
|
export interface NormalizedOptions extends LibraryGeneratorOptions {
|
||||||
|
|||||||
@ -122,6 +122,12 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
|
"description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
@ -16,4 +16,5 @@ export interface Schema {
|
|||||||
standaloneConfig?: boolean;
|
standaloneConfig?: boolean;
|
||||||
swc?: boolean;
|
swc?: boolean;
|
||||||
customServer?: boolean;
|
customServer?: boolean;
|
||||||
|
skipPackageJson?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,6 +118,12 @@
|
|||||||
"description": "Use a custom Express server for the Next.js application.",
|
"description": "Use a custom Express server for the Next.js application.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [],
|
"required": [],
|
||||||
|
|||||||
@ -58,8 +58,10 @@ export async function nextInitGenerator(host: Tree, schema: InitSchema) {
|
|||||||
const reactTask = await reactInitGenerator(host, schema);
|
const reactTask = await reactInitGenerator(host, schema);
|
||||||
tasks.push(reactTask);
|
tasks.push(reactTask);
|
||||||
|
|
||||||
|
if (!schema.skipPackageJson) {
|
||||||
const installTask = updateDependencies(host);
|
const installTask = updateDependencies(host);
|
||||||
tasks.push(installTask);
|
tasks.push(installTask);
|
||||||
|
}
|
||||||
|
|
||||||
addGitIgnoreEntry(host);
|
addGitIgnoreEntry(host);
|
||||||
|
|
||||||
|
|||||||
@ -3,4 +3,5 @@ export interface InitSchema {
|
|||||||
e2eTestRunner?: 'cypress' | 'none';
|
e2eTestRunner?: 'cypress' | 'none';
|
||||||
skipFormat?: boolean;
|
skipFormat?: boolean;
|
||||||
js?: boolean;
|
js?: boolean;
|
||||||
|
skipPackageJson?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,12 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Use JavaScript instead of TypeScript"
|
"description": "Use JavaScript instead of TypeScript"
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": []
|
"required": []
|
||||||
|
|||||||
@ -22,4 +22,5 @@ export interface Schema {
|
|||||||
strict?: boolean;
|
strict?: boolean;
|
||||||
setParserOptionsProject?: boolean;
|
setParserOptionsProject?: boolean;
|
||||||
standaloneConfig?: boolean;
|
standaloneConfig?: boolean;
|
||||||
|
skipPackageJson?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,6 +149,12 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
"x-deprecated": "Nx only supports standaloneConfig"
|
"x-deprecated": "Nx only supports standaloneConfig"
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name"],
|
"required": ["name"],
|
||||||
|
|||||||
@ -65,7 +65,10 @@ export async function reactNativeInitGenerator(host: Tree, schema: Schema) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'detox') {
|
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'detox') {
|
||||||
const detoxTask = await detoxInitGenerator(host, {});
|
const detoxTask = await detoxInitGenerator(host, {
|
||||||
|
...schema,
|
||||||
|
skipFormat: true,
|
||||||
|
});
|
||||||
tasks.push(detoxTask);
|
tasks.push(detoxTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user