@nx/plugin 16.4.0-beta.8 → 16.4.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/generators/create-package/create-package.js +8 -22
- package/src/generators/create-package/files/e2e/__cliName__.spec.ts__tmpl__ +31 -0
- package/src/generators/create-package/schema.d.ts +1 -1
- package/src/generators/create-package/schema.json +7 -4
- package/src/generators/e2e-project/e2e.js +10 -2
- package/src/generators/e2e-project/files/tests/__pluginName__.spec.ts__tmpl__ +0 -1
- package/src/utils/testing-utils/index.d.ts +0 -1
- package/src/utils/testing-utils/index.js +0 -1
- package/src/generators/create-package/files/e2e/__name__.spec.ts__tmpl__ +0 -29
- package/src/utils/testing-utils/create-package-cli.d.ts +0 -18
- package/src/utils/testing-utils/create-package-cli.js +0 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/plugin",
|
|
3
|
-
"version": "16.4.0-beta.
|
|
3
|
+
"version": "16.4.0-beta.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This plugin is used to create Nx plugins! It contains generators for generating common plugin features like generators, executors, migrations and more.",
|
|
6
6
|
"repository": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"migrations": "./migrations.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@nrwl/nx-plugin": "16.4.0-beta.
|
|
32
|
-
"@nx/devkit": "16.4.0-beta.
|
|
33
|
-
"@nx/jest": "16.4.0-beta.
|
|
34
|
-
"@nx/js": "16.4.0-beta.
|
|
35
|
-
"@nx/linter": "16.4.0-beta.
|
|
31
|
+
"@nrwl/nx-plugin": "16.4.0-beta.9",
|
|
32
|
+
"@nx/devkit": "16.4.0-beta.9",
|
|
33
|
+
"@nx/jest": "16.4.0-beta.9",
|
|
34
|
+
"@nx/js": "16.4.0-beta.9",
|
|
35
|
+
"@nx/linter": "16.4.0-beta.9",
|
|
36
36
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
37
37
|
"dotenv": "~10.0.0",
|
|
38
38
|
"fs-extra": "^11.1.0",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "b7fbc25d5be1789d42805e2254cf4a6070889157"
|
|
45
45
|
}
|
|
@@ -7,7 +7,6 @@ const js_1 = require("@nx/js");
|
|
|
7
7
|
const versions_1 = require("nx/src/utils/versions");
|
|
8
8
|
const generator_1 = require("../generator/generator");
|
|
9
9
|
const normalize_schema_1 = require("./utils/normalize-schema");
|
|
10
|
-
const e2e_1 = require("../e2e-project/e2e");
|
|
11
10
|
const has_generator_1 = require("../../utils/has-generator");
|
|
12
11
|
function createPackageGenerator(host, schema) {
|
|
13
12
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -19,6 +18,9 @@ function createPackageGenerator(host, schema) {
|
|
|
19
18
|
}, {});
|
|
20
19
|
tasks.push(installTask);
|
|
21
20
|
yield createCliPackage(host, options, pluginPackageName);
|
|
21
|
+
if (options.e2eProject) {
|
|
22
|
+
addE2eProject(host, options);
|
|
23
|
+
}
|
|
22
24
|
if (!options.skipFormat) {
|
|
23
25
|
yield (0, devkit_1.formatFiles)(host);
|
|
24
26
|
}
|
|
@@ -84,27 +86,11 @@ function createCliPackage(host, options, pluginPackageName) {
|
|
|
84
86
|
* @returns
|
|
85
87
|
*/
|
|
86
88
|
function addE2eProject(host, options) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const e2eTask = yield (0, e2e_1.default)(host, {
|
|
93
|
-
pluginName: options.projectName,
|
|
94
|
-
projectDirectory: options.projectDirectory,
|
|
95
|
-
pluginOutputPath,
|
|
96
|
-
npmPackageName: options.name,
|
|
97
|
-
skipFormat: true,
|
|
98
|
-
rootProject: false,
|
|
99
|
-
});
|
|
100
|
-
const e2eProjectConfiguration = (0, devkit_1.readProjectConfiguration)(host, `${options.projectName}-e2e`);
|
|
101
|
-
e2eProjectConfiguration.targets.e2e.dependsOn = ['^build'];
|
|
102
|
-
(0, devkit_1.updateProjectConfiguration)(host, e2eProjectConfiguration.name, e2eProjectConfiguration);
|
|
103
|
-
// delete the default e2e test file
|
|
104
|
-
host.delete(e2eProjectConfiguration.sourceRoot);
|
|
105
|
-
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/e2e'), e2eProjectConfiguration.sourceRoot, Object.assign(Object.assign({}, options), { pluginOutputPath,
|
|
106
|
-
cliOutputPath, tmpl: '' }));
|
|
107
|
-
return e2eTask;
|
|
89
|
+
const e2eProjectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.e2eProject);
|
|
90
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/e2e'), e2eProjectConfiguration.sourceRoot, {
|
|
91
|
+
pluginName: options.project,
|
|
92
|
+
cliName: options.name,
|
|
93
|
+
tmpl: '',
|
|
108
94
|
});
|
|
109
95
|
}
|
|
110
96
|
exports.default = createPackageGenerator;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkFilesExist,
|
|
3
|
+
removeTmpProject,
|
|
4
|
+
tmpFolder,
|
|
5
|
+
uniq,
|
|
6
|
+
} from '@nx/plugin/testing';
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
import { join } from 'path';
|
|
9
|
+
|
|
10
|
+
describe('<%= cliName %> e2e', () => {
|
|
11
|
+
let project: string;
|
|
12
|
+
beforeAll(async () => {
|
|
13
|
+
// create a workspace with cli
|
|
14
|
+
project = uniq('<%= cliName %>');
|
|
15
|
+
execSync(`npx <%= cliName %>@1.0.0 ${project}`, {
|
|
16
|
+
cwd: tmpFolder(),
|
|
17
|
+
env: process.env,
|
|
18
|
+
});
|
|
19
|
+
}, 240_000);
|
|
20
|
+
|
|
21
|
+
afterAll(() => {
|
|
22
|
+
// Remove the generated project from the file system
|
|
23
|
+
removeTmpProject(project);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should create project using <%= cliName %>', () => {
|
|
27
|
+
expect(() =>
|
|
28
|
+
checkFilesExist(join(tmpFolder(), project, 'package.json'))
|
|
29
|
+
).not.toThrow();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -59,11 +59,14 @@
|
|
|
59
59
|
"default": "tsc",
|
|
60
60
|
"description": "The compiler used by the build and test targets."
|
|
61
61
|
},
|
|
62
|
-
"
|
|
62
|
+
"e2eProject": {
|
|
63
63
|
"type": "string",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"default":
|
|
64
|
+
"description": "The name of the e2e project.",
|
|
65
|
+
"alias": "p",
|
|
66
|
+
"$default": {
|
|
67
|
+
"$source": "projectName"
|
|
68
|
+
},
|
|
69
|
+
"x-prompt": "What is the name of the e2e project?"
|
|
67
70
|
}
|
|
68
71
|
},
|
|
69
72
|
"required": ["name", "project"]
|
|
@@ -5,7 +5,9 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const jest_1 = require("@nx/jest");
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
|
-
const
|
|
8
|
+
const generator_1 = require("@nx/js/src/generators/setup-verdaccio/generator");
|
|
9
|
+
const add_local_registry_scripts_1 = require("@nx/js/src/utils/add-local-registry-scripts");
|
|
10
|
+
const path_1 = require("path");
|
|
9
11
|
const linter_1 = require("@nx/linter");
|
|
10
12
|
function normalizeOptions(host, options) {
|
|
11
13
|
var _a;
|
|
@@ -32,7 +34,7 @@ function validatePlugin(host, pluginName) {
|
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
function addFiles(host, options) {
|
|
35
|
-
(0, devkit_1.generateFiles)(host,
|
|
37
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), options.projectRoot, Object.assign(Object.assign({}, options), { tmpl: '', rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot) }));
|
|
36
38
|
}
|
|
37
39
|
function addJest(host, options) {
|
|
38
40
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -50,6 +52,9 @@ function addJest(host, options) {
|
|
|
50
52
|
skipSerializers: true,
|
|
51
53
|
skipFormat: true,
|
|
52
54
|
});
|
|
55
|
+
const { startLocalRegistryPath, stopLocalRegistryPath } = (0, add_local_registry_scripts_1.addLocalRegistryScripts)(host);
|
|
56
|
+
(0, jest_1.addPropertyToJestConfig)(host, (0, path_1.join)(options.projectRoot, 'jest.config.ts'), 'globalSetup', (0, path_1.join)((0, devkit_1.offsetFromRoot)(options.projectRoot), startLocalRegistryPath));
|
|
57
|
+
(0, jest_1.addPropertyToJestConfig)(host, (0, path_1.join)(options.projectRoot, 'jest.config.ts'), 'globalTeardown', (0, path_1.join)((0, devkit_1.offsetFromRoot)(options.projectRoot), stopLocalRegistryPath));
|
|
53
58
|
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
54
59
|
const testTarget = project.targets.test;
|
|
55
60
|
project.targets.e2e = Object.assign(Object.assign({}, testTarget), { dependsOn: [`^build`], options: Object.assign(Object.assign({}, testTarget.options), { runInBand: true }), configurations: testTarget.configurations });
|
|
@@ -81,6 +86,9 @@ function e2eProjectGenerator(host, schema) {
|
|
|
81
86
|
validatePlugin(host, schema.pluginName);
|
|
82
87
|
const options = normalizeOptions(host, schema);
|
|
83
88
|
addFiles(host, options);
|
|
89
|
+
tasks.push(yield (0, generator_1.setupVerdaccio)(host, {
|
|
90
|
+
skipFormat: true,
|
|
91
|
+
}));
|
|
84
92
|
tasks.push(yield addJest(host, options));
|
|
85
93
|
if (options.linter !== linter_1.Linter.None) {
|
|
86
94
|
tasks.push(yield addLintingToApplication(host, Object.assign({}, options)));
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./async-commands"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./commands"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./create-package-cli"), exports);
|
|
7
6
|
tslib_1.__exportStar(require("./paths"), exports);
|
|
8
7
|
tslib_1.__exportStar(require("./nx-project"), exports);
|
|
9
8
|
tslib_1.__exportStar(require("./utils"), exports);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
runCreatePackageCli,
|
|
3
|
-
removeTmpProject,
|
|
4
|
-
} from '@nx/plugin/testing';
|
|
5
|
-
|
|
6
|
-
describe('<%= name %> e2e', () => {
|
|
7
|
-
const project = '<%= name %>';
|
|
8
|
-
let createPackageResult;
|
|
9
|
-
|
|
10
|
-
beforeAll(async () => {
|
|
11
|
-
// Create project using CLI command
|
|
12
|
-
createPackageResult = await runCreatePackageCli(
|
|
13
|
-
project,
|
|
14
|
-
{
|
|
15
|
-
pluginLibraryBuildPath: '<%= pluginOutputPath %>',
|
|
16
|
-
createPackageLibraryBuildPath: '<%= cliOutputPath %>',
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
}, 240_000);
|
|
20
|
-
|
|
21
|
-
afterAll(() => {
|
|
22
|
-
// Remove the generated project from the file system
|
|
23
|
-
removeTmpProject(project);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should create project using <%= name %>', () => {
|
|
27
|
-
expect(createPackageResult).toContain('Successfully created');
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This function is used to run the create package CLI command.
|
|
3
|
-
* It builds the plugin library and the create package library and run the create package command with for the plugin library.
|
|
4
|
-
* It needs to be ran inside an Nx project. It would assume that an Nx project already exists.
|
|
5
|
-
* @param projectToBeCreated project name to be created using the cli
|
|
6
|
-
* @param pluginLibraryBuildPath e.g. dist/packages/my-plugin
|
|
7
|
-
* @param createPackageLibraryBuildPath e.g. dist/packages/create-my-plugin-package
|
|
8
|
-
* @param extraArguments extra arguments to be passed to the create package command
|
|
9
|
-
* @param verbose if true, NX_VERBOSE_LOGGING will be set to true
|
|
10
|
-
* @returns results for the create package command
|
|
11
|
-
*/
|
|
12
|
-
export declare function runCreatePackageCli(projectToBeCreated: string, { pluginLibraryBuildPath, createPackageLibraryBuildPath, extraArguments, verbose, }: {
|
|
13
|
-
pluginLibraryBuildPath: string;
|
|
14
|
-
createPackageLibraryBuildPath: string;
|
|
15
|
-
extraArguments?: string[];
|
|
16
|
-
verbose?: boolean;
|
|
17
|
-
}): Promise<string>;
|
|
18
|
-
export declare function generatedPackagePath(projectToBeCreated: string): string;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generatedPackagePath = exports.runCreatePackageCli = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const paths_1 = require("./paths");
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
7
|
-
/**
|
|
8
|
-
* This function is used to run the create package CLI command.
|
|
9
|
-
* It builds the plugin library and the create package library and run the create package command with for the plugin library.
|
|
10
|
-
* It needs to be ran inside an Nx project. It would assume that an Nx project already exists.
|
|
11
|
-
* @param projectToBeCreated project name to be created using the cli
|
|
12
|
-
* @param pluginLibraryBuildPath e.g. dist/packages/my-plugin
|
|
13
|
-
* @param createPackageLibraryBuildPath e.g. dist/packages/create-my-plugin-package
|
|
14
|
-
* @param extraArguments extra arguments to be passed to the create package command
|
|
15
|
-
* @param verbose if true, NX_VERBOSE_LOGGING will be set to true
|
|
16
|
-
* @returns results for the create package command
|
|
17
|
-
*/
|
|
18
|
-
function runCreatePackageCli(projectToBeCreated, { pluginLibraryBuildPath, createPackageLibraryBuildPath, extraArguments, verbose, }) {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
const childProcess = (0, child_process_1.fork)(`${devkit_1.workspaceRoot}/${createPackageLibraryBuildPath}/bin/index.js`, [projectToBeCreated, ...(extraArguments || [])], {
|
|
21
|
-
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
|
22
|
-
env: Object.assign(Object.assign(Object.assign({}, process.env), { [`NX_E2E_PRESET_VERSION`]: `file:${devkit_1.workspaceRoot}/${pluginLibraryBuildPath}` }), (verbose && { NX_VERBOSE_LOGGING: 'true' })),
|
|
23
|
-
cwd: (0, paths_1.tmpFolder)(),
|
|
24
|
-
});
|
|
25
|
-
// Ensure the child process is killed when the parent exits
|
|
26
|
-
process.on('exit', () => childProcess.kill());
|
|
27
|
-
process.on('SIGTERM', () => childProcess.kill());
|
|
28
|
-
let allMessages = '';
|
|
29
|
-
childProcess.on('message', (message) => {
|
|
30
|
-
allMessages += message;
|
|
31
|
-
});
|
|
32
|
-
childProcess.stdout.on('data', (data) => {
|
|
33
|
-
allMessages += data;
|
|
34
|
-
});
|
|
35
|
-
childProcess.on('error', (error) => {
|
|
36
|
-
reject(error);
|
|
37
|
-
});
|
|
38
|
-
childProcess.on('exit', (code) => {
|
|
39
|
-
if (code === 0) {
|
|
40
|
-
resolve(allMessages);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
reject(allMessages);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
exports.runCreatePackageCli = runCreatePackageCli;
|
|
49
|
-
function generatedPackagePath(projectToBeCreated) {
|
|
50
|
-
return `${(0, paths_1.tmpFolder)()}/${projectToBeCreated}`;
|
|
51
|
-
}
|
|
52
|
-
exports.generatedPackagePath = generatedPackagePath;
|