@nx/plugin 16.4.0-beta.10 → 16.4.0-beta.13
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/executors/e2e/e2e.impl.js +11 -21
- package/src/generators/create-package/create-package.js +5 -0
- package/src/generators/create-package/files/e2e/__cliName__.spec.ts__tmpl__ +49 -24
- package/src/generators/e2e-project/e2e.js +5 -4
- package/src/generators/e2e-project/files/tests/__pluginName__.spec.ts__tmpl__ +58 -27
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.13",
|
|
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.13",
|
|
32
|
+
"@nx/devkit": "16.4.0-beta.13",
|
|
33
|
+
"@nx/jest": "16.4.0-beta.13",
|
|
34
|
+
"@nx/js": "16.4.0-beta.13",
|
|
35
|
+
"@nx/linter": "16.4.0-beta.13",
|
|
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": "d81afedfcc8d07db8cdb9b0e9286de0321ee184e"
|
|
45
45
|
}
|
|
@@ -19,21 +19,16 @@ function nxPluginE2EExecutor(options, context) {
|
|
|
19
19
|
});
|
|
20
20
|
let success;
|
|
21
21
|
try {
|
|
22
|
-
for (var _d = true, _e = tslib_1.__asyncValues(runBuildTarget(target, context)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a;) {
|
|
22
|
+
for (var _d = true, _e = tslib_1.__asyncValues(runBuildTarget(target, context)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
23
23
|
_c = _f.value;
|
|
24
24
|
_d = false;
|
|
25
|
+
const _ = _c;
|
|
25
26
|
try {
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
success = yield tslib_1.__await(runTests(jestOptions, context));
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
devkit_1.logger.error(e.message);
|
|
32
|
-
success = false;
|
|
33
|
-
}
|
|
27
|
+
success = yield tslib_1.__await(runTests(jestOptions, context));
|
|
34
28
|
}
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
catch (e) {
|
|
30
|
+
devkit_1.logger.error(e.message);
|
|
31
|
+
success = false;
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
34
|
}
|
|
@@ -56,18 +51,13 @@ function runBuildTarget(buildTarget, context) {
|
|
|
56
51
|
const buildTargetOptions = (0, devkit_1.readTargetOptions)({ project, target, configuration }, context);
|
|
57
52
|
const targetSupportsWatch = Object.keys(buildTargetOptions).includes('watch');
|
|
58
53
|
try {
|
|
59
|
-
for (var _d = true, _e = tslib_1.__asyncValues(yield tslib_1.__await((0, devkit_1.runExecutor)({ project, target, configuration }, targetSupportsWatch ? { watch: false } : {}, context))), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a;) {
|
|
54
|
+
for (var _d = true, _e = tslib_1.__asyncValues(yield tslib_1.__await((0, devkit_1.runExecutor)({ project, target, configuration }, targetSupportsWatch ? { watch: false } : {}, context))), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
60
55
|
_c = _f.value;
|
|
61
56
|
_d = false;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
yield yield tslib_1.__await(output.success);
|
|
67
|
-
}
|
|
68
|
-
finally {
|
|
69
|
-
_d = true;
|
|
70
|
-
}
|
|
57
|
+
const output = _c;
|
|
58
|
+
if (!output.success)
|
|
59
|
+
throw new Error('Could not compile application files.');
|
|
60
|
+
yield yield tslib_1.__await(output.success);
|
|
71
61
|
}
|
|
72
62
|
}
|
|
73
63
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -8,6 +8,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
10
|
const has_generator_1 = require("../../utils/has-generator");
|
|
11
|
+
const path_1 = require("path");
|
|
11
12
|
function createPackageGenerator(host, schema) {
|
|
12
13
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
14
|
const tasks = [];
|
|
@@ -87,9 +88,13 @@ function createCliPackage(host, options, pluginPackageName) {
|
|
|
87
88
|
*/
|
|
88
89
|
function addE2eProject(host, options) {
|
|
89
90
|
const e2eProjectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.e2eProject);
|
|
91
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
92
|
+
const { name: pluginPackageName } = (0, devkit_1.readJson)(host, (0, path_1.join)(projectConfiguration.root, 'package.json'));
|
|
90
93
|
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/e2e'), e2eProjectConfiguration.sourceRoot, {
|
|
91
94
|
pluginName: options.project,
|
|
92
95
|
cliName: options.name,
|
|
96
|
+
packageManagerCommands: (0, devkit_1.getPackageManagerCommand)('npm'),
|
|
97
|
+
pluginPackageName,
|
|
93
98
|
tmpl: '',
|
|
94
99
|
});
|
|
95
100
|
}
|
|
@@ -1,31 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
checkFilesExist,
|
|
3
|
-
removeTmpProject,
|
|
4
|
-
tmpFolder,
|
|
5
|
-
uniq,
|
|
6
|
-
} from '@nx/plugin/testing';
|
|
7
1
|
import { execSync } from 'child_process';
|
|
8
|
-
import { join } from 'path';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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);
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { mkdirSync, rmSync } from 'fs';
|
|
4
|
+
|
|
5
|
+
describe('<%= cliName %>', () => {
|
|
6
|
+
let projectDirectory: string;
|
|
20
7
|
|
|
21
8
|
afterAll(() => {
|
|
22
|
-
//
|
|
23
|
-
|
|
9
|
+
// Cleanup the test project
|
|
10
|
+
rmSync(projectDirectory, {
|
|
11
|
+
recursive: true,
|
|
12
|
+
force: true,
|
|
13
|
+
});
|
|
24
14
|
});
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
|
|
17
|
+
it('should be installed', () => {
|
|
18
|
+
projectDirectory = createTestProject();
|
|
19
|
+
|
|
20
|
+
// npm ls will fail if the package is not installed properly
|
|
21
|
+
execSync('<%= packageManagerCommands.list %> <%= pluginPackageName %>', {
|
|
22
|
+
cwd: projectDirectory,
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
});
|
|
30
25
|
});
|
|
31
26
|
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates a test project with create-nx-workspace and installs the plugin
|
|
30
|
+
* @returns The directory where the test project was created
|
|
31
|
+
*/
|
|
32
|
+
function createTestProject(extraArgs: string = '') {
|
|
33
|
+
const projectName = 'test-project';
|
|
34
|
+
const projectDirectory = join(process.cwd(), 'tmp', projectName);
|
|
35
|
+
|
|
36
|
+
// Ensure projectDirectory is empty
|
|
37
|
+
rmSync(projectDirectory, {
|
|
38
|
+
recursive: true,
|
|
39
|
+
force: true,
|
|
40
|
+
});
|
|
41
|
+
mkdirSync(dirname(projectDirectory), {
|
|
42
|
+
recursive: true,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
execSync(
|
|
46
|
+
`<%= packageManagerCommands.exec %> --yes <%= cliName %>@e2e ${projectName} ${extraArgs}`,
|
|
47
|
+
{
|
|
48
|
+
cwd: dirname(projectDirectory),
|
|
49
|
+
stdio: 'inherit',
|
|
50
|
+
env: process.env,
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
console.log(`Created test project in "${projectDirectory}"`);
|
|
54
|
+
|
|
55
|
+
return projectDirectory;
|
|
56
|
+
}
|
|
@@ -12,7 +12,7 @@ const linter_1 = require("@nx/linter");
|
|
|
12
12
|
function normalizeOptions(host, options) {
|
|
13
13
|
var _a;
|
|
14
14
|
const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.projectDirectory);
|
|
15
|
-
const {
|
|
15
|
+
const { appsDir: defaultAppsDir } = (0, devkit_1.getWorkspaceLayout)(host);
|
|
16
16
|
const appsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : defaultAppsDir;
|
|
17
17
|
const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
|
|
18
18
|
const projectRoot = projectDirectory && !options.rootProject
|
|
@@ -22,8 +22,7 @@ function normalizeOptions(host, options) {
|
|
|
22
22
|
: (0, devkit_1.joinPathFragments)(appsDir, projectName);
|
|
23
23
|
const pluginPropertyName = (0, devkit_1.names)(options.pluginName).propertyName;
|
|
24
24
|
return Object.assign(Object.assign({}, options), { projectName, linter: (_a = options.linter) !== null && _a !== void 0 ? _a : linter_1.Linter.EsLint, pluginPropertyName,
|
|
25
|
-
projectRoot
|
|
26
|
-
npmScope });
|
|
25
|
+
projectRoot });
|
|
27
26
|
}
|
|
28
27
|
function validatePlugin(host, pluginName) {
|
|
29
28
|
try {
|
|
@@ -34,7 +33,9 @@ function validatePlugin(host, pluginName) {
|
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
function addFiles(host, options) {
|
|
37
|
-
|
|
36
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.pluginName);
|
|
37
|
+
const { name: pluginPackageName } = (0, devkit_1.readJson)(host, (0, path_1.join)(projectConfiguration.root, 'package.json'));
|
|
38
|
+
(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), packageManagerCommands: (0, devkit_1.getPackageManagerCommand)('npm'), pluginPackageName }));
|
|
38
39
|
}
|
|
39
40
|
function addJest(host, options) {
|
|
40
41
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,35 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
describe('<%= pluginName %> e2e', () => {
|
|
9
|
-
// Setting up individual workspaces per
|
|
10
|
-
// test can cause e2e runs to take a long time.
|
|
11
|
-
// For this reason, we recommend each suite only
|
|
12
|
-
// consumes 1 workspace. The tests should each operate
|
|
13
|
-
// on a unique project in the workspace, such that they
|
|
14
|
-
// are not dependant on one another.
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { mkdirSync, rmSync } from 'fs';
|
|
4
|
+
|
|
5
|
+
describe('<%= pluginName %>', () => {
|
|
6
|
+
let projectDirectory: string;
|
|
7
|
+
|
|
15
8
|
beforeAll(() => {
|
|
16
|
-
|
|
9
|
+
projectDirectory = createTestProject();
|
|
10
|
+
|
|
11
|
+
// The plugin has been built and published to a local registry in the jest globalSetup
|
|
12
|
+
// Install the plugin built with the latest source code into the test repo
|
|
13
|
+
execSync(`<%= packageManagerCommands.install %> <%= pluginPackageName %>@e2e`, {
|
|
14
|
+
cwd: projectDirectory,
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
env: process.env,
|
|
17
|
+
});
|
|
17
18
|
});
|
|
18
19
|
|
|
19
|
-
afterAll(
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
afterAll(() => {
|
|
21
|
+
// Cleanup the test project
|
|
22
|
+
rmSync(projectDirectory, {
|
|
23
|
+
recursive: true,
|
|
24
|
+
force: true,
|
|
25
|
+
});
|
|
23
26
|
});
|
|
24
27
|
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
expect(() => runNxCommand('build ${proj}')).not.toThrow();
|
|
33
|
-
expect(() => checkFilesExist(`dist/${name}/index.js`)).not.toThrow();
|
|
29
|
+
it('should be installed', () => {
|
|
30
|
+
// npm ls will fail if the package is not installed properly
|
|
31
|
+
execSync('<%= packageManagerCommands.list %> <%= pluginPackageName %>', {
|
|
32
|
+
cwd: projectDirectory,
|
|
33
|
+
stdio: 'inherit',
|
|
34
|
+
});
|
|
34
35
|
});
|
|
35
36
|
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a test project with create-nx-workspace and installs the plugin
|
|
40
|
+
* @returns The directory where the test project was created
|
|
41
|
+
*/
|
|
42
|
+
function createTestProject() {
|
|
43
|
+
const projectName = 'test-project';
|
|
44
|
+
const projectDirectory = join(process.cwd(), 'tmp', projectName);
|
|
45
|
+
|
|
46
|
+
// Ensure projectDirectory is empty
|
|
47
|
+
rmSync(projectDirectory, {
|
|
48
|
+
recursive: true,
|
|
49
|
+
force: true,
|
|
50
|
+
});
|
|
51
|
+
mkdirSync(dirname(projectDirectory), {
|
|
52
|
+
recursive: true,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
execSync(
|
|
56
|
+
`<%= packageManagerCommands.exec %> --yes create-nx-workspace@latest ${projectName} --preset empty --no-nxCloud --no-interactive`,
|
|
57
|
+
{
|
|
58
|
+
cwd: dirname(projectDirectory),
|
|
59
|
+
stdio: 'inherit',
|
|
60
|
+
env: process.env,
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
console.log(`Created test project in "${projectDirectory}"`);
|
|
64
|
+
|
|
65
|
+
return projectDirectory;
|
|
66
|
+
}
|