@nx/plugin 16.4.0-beta.8 → 16.4.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/plugin",
3
- "version": "16.4.0-beta.8",
3
+ "version": "16.4.0",
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.8",
32
- "@nx/devkit": "16.4.0-beta.8",
33
- "@nx/jest": "16.4.0-beta.8",
34
- "@nx/js": "16.4.0-beta.8",
35
- "@nx/linter": "16.4.0-beta.8",
31
+ "@nrwl/nx-plugin": "16.4.0",
32
+ "@nx/devkit": "16.4.0",
33
+ "@nx/jest": "16.4.0",
34
+ "@nx/js": "16.4.0",
35
+ "@nx/linter": "16.4.0",
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": "a6589ab111fc01fd4d2cd215c31bfcff004dfc00"
44
+ "gitHead": "ae698a72748d9f33aa5395aeeaa7b7af436a1dc5"
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
- const _ = _c;
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
- finally {
36
- _d = true;
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
- try {
63
- const output = _c;
64
- if (!output.success)
65
- throw new Error('Could not compile application files.');
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 }; }
@@ -7,8 +7,8 @@ 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");
11
+ const path_1 = require("path");
12
12
  function createPackageGenerator(host, schema) {
13
13
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
14
  const tasks = [];
@@ -19,6 +19,9 @@ function createPackageGenerator(host, schema) {
19
19
  }, {});
20
20
  tasks.push(installTask);
21
21
  yield createCliPackage(host, options, pluginPackageName);
22
+ if (options.e2eProject) {
23
+ addE2eProject(host, options);
24
+ }
22
25
  if (!options.skipFormat) {
23
26
  yield (0, devkit_1.formatFiles)(host);
24
27
  }
@@ -84,27 +87,15 @@ function createCliPackage(host, options, pluginPackageName) {
84
87
  * @returns
85
88
  */
86
89
  function addE2eProject(host, options) {
87
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
88
- const pluginProjectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.project);
89
- const pluginOutputPath = pluginProjectConfiguration.targets.build.options.outputPath;
90
- const cliProjectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
91
- const cliOutputPath = cliProjectConfiguration.targets.build.options.outputPath;
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;
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'));
93
+ (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/e2e'), e2eProjectConfiguration.sourceRoot, {
94
+ pluginName: options.project,
95
+ cliName: options.name,
96
+ packageManagerCommands: (0, devkit_1.getPackageManagerCommand)('npm'),
97
+ pluginPackageName,
98
+ tmpl: '',
108
99
  });
109
100
  }
110
101
  exports.default = createPackageGenerator;
@@ -0,0 +1,56 @@
1
+ import { execSync } from 'child_process';
2
+ import { join, dirname } from 'path';
3
+ import { mkdirSync, rmSync } from 'fs';
4
+
5
+ describe('<%= cliName %>', () => {
6
+ let projectDirectory: string;
7
+
8
+ afterAll(() => {
9
+ // Cleanup the test project
10
+ rmSync(projectDirectory, {
11
+ recursive: true,
12
+ force: true,
13
+ });
14
+ });
15
+
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
+ });
25
+ });
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
+ }
@@ -13,5 +13,5 @@ export interface CreatePackageSchema {
13
13
  compiler: 'swc' | 'tsc';
14
14
 
15
15
  // options to create e2e project, passed to e2e project generator
16
- e2eTestRunner?: 'jest' | 'none';
16
+ e2eProject?: string;
17
17
  }
@@ -59,11 +59,14 @@
59
59
  "default": "tsc",
60
60
  "description": "The compiler used by the build and test targets."
61
61
  },
62
- "e2eTestRunner": {
62
+ "e2eProject": {
63
63
  "type": "string",
64
- "enum": ["jest", "none"],
65
- "description": "Test runner to use for end to end (E2E) tests.",
66
- "default": "jest"
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,12 +5,14 @@ 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 path = require("path");
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;
12
14
  const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.projectDirectory);
13
- const { npmScope, appsDir: defaultAppsDir } = (0, devkit_1.getWorkspaceLayout)(host);
15
+ const { appsDir: defaultAppsDir } = (0, devkit_1.getWorkspaceLayout)(host);
14
16
  const appsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : defaultAppsDir;
15
17
  const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
16
18
  const projectRoot = projectDirectory && !options.rootProject
@@ -20,8 +22,7 @@ function normalizeOptions(host, options) {
20
22
  : (0, devkit_1.joinPathFragments)(appsDir, projectName);
21
23
  const pluginPropertyName = (0, devkit_1.names)(options.pluginName).propertyName;
22
24
  return Object.assign(Object.assign({}, options), { projectName, linter: (_a = options.linter) !== null && _a !== void 0 ? _a : linter_1.Linter.EsLint, pluginPropertyName,
23
- projectRoot,
24
- npmScope });
25
+ projectRoot });
25
26
  }
26
27
  function validatePlugin(host, pluginName) {
27
28
  try {
@@ -32,7 +33,9 @@ function validatePlugin(host, pluginName) {
32
33
  }
33
34
  }
34
35
  function addFiles(host, options) {
35
- (0, devkit_1.generateFiles)(host, path.join(__dirname, './files'), options.projectRoot, Object.assign(Object.assign({}, options), { tmpl: '', rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot) }));
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 }));
36
39
  }
37
40
  function addJest(host, options) {
38
41
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -50,6 +53,9 @@ function addJest(host, options) {
50
53
  skipSerializers: true,
51
54
  skipFormat: true,
52
55
  });
56
+ const { startLocalRegistryPath, stopLocalRegistryPath } = (0, add_local_registry_scripts_1.addLocalRegistryScripts)(host);
57
+ (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));
58
+ (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
59
  const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
54
60
  const testTarget = project.targets.test;
55
61
  project.targets.e2e = Object.assign(Object.assign({}, testTarget), { dependsOn: [`^build`], options: Object.assign(Object.assign({}, testTarget.options), { runInBand: true }), configurations: testTarget.configurations });
@@ -81,6 +87,9 @@ function e2eProjectGenerator(host, schema) {
81
87
  validatePlugin(host, schema.pluginName);
82
88
  const options = normalizeOptions(host, schema);
83
89
  addFiles(host, options);
90
+ tasks.push(yield (0, generator_1.setupVerdaccio)(host, {
91
+ skipFormat: true,
92
+ }));
84
93
  tasks.push(yield addJest(host, options));
85
94
  if (options.linter !== linter_1.Linter.None) {
86
95
  tasks.push(yield addLintingToApplication(host, Object.assign({}, options)));
@@ -1,36 +1,66 @@
1
- import {
2
- checkFilesExist,
3
- ensureNxProject,
4
- readJson,
5
- runNxCommandAsync,
6
- runNxCommand,
7
- } from '@nx/plugin/testing';
8
-
9
- describe('<%= pluginName %> e2e', () => {
10
- // Setting up individual workspaces per
11
- // test can cause e2e runs to take a long time.
12
- // For this reason, we recommend each suite only
13
- // consumes 1 workspace. The tests should each operate
14
- // on a unique project in the workspace, such that they
15
- // 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
+
16
8
  beforeAll(() => {
17
- ensureNxProject('<%= npmPackageName %>', '<%= pluginOutputPath %>');
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
+ });
18
18
  });
19
19
 
20
- afterAll(async () => {
21
- // `nx reset` kills the daemon, and performs
22
- // some work which can help clean up e2e leftovers
23
- await runNxCommandAsync('reset');
20
+ afterAll(() => {
21
+ // Cleanup the test project
22
+ rmSync(projectDirectory, {
23
+ recursive: true,
24
+ force: true,
25
+ });
24
26
  });
25
27
 
26
28
 
27
- // Add some tests here to check that your plugin functionality works as expected.
28
- // A sample test is included below to give you some ideas.
29
- xit('should be able to build generated projects', async () => {
30
- const name = 'proj';
31
- const generator = 'PLACEHOLDER';
32
- await runNxCommandAsync(`generate <%= npmPackageName %>:${generator} --name ${name}`);
33
- expect(() => runNxCommand('build ${proj}')).not.toThrow();
34
- 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
+ });
35
35
  });
36
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
+ }
@@ -1,7 +1,7 @@
1
1
  import { ProjectConfiguration, TargetConfiguration, Tree } from '@nx/devkit';
2
- import { Schema as EsLintExecutorOptions } from '@nx/linter/src/executors/eslint/schema';
2
+ import type { Schema as EsLintExecutorOptions } from '@nx/linter/src/executors/eslint/schema';
3
3
  import { PluginLintChecksGeneratorSchema } from './schema';
4
4
  import { PackageJson } from 'nx/src/utils/package-json';
5
- export default function pluginLintCheckGenerator(host: Tree, options: PluginLintChecksGeneratorSchema): Promise<() => import("@nx/devkit").GeneratorCallback>;
5
+ export default function pluginLintCheckGenerator(host: Tree, options: PluginLintChecksGeneratorSchema): Promise<void>;
6
6
  export declare function addMigrationJsonChecks(host: Tree, options: PluginLintChecksGeneratorSchema, packageJson: PackageJson): void;
7
7
  export declare function getEsLintOptions(project: ProjectConfiguration): [target: string, configuration: TargetConfiguration<EsLintExecutorOptions>];
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEsLintOptions = exports.addMigrationJsonChecks = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
- const versions_1 = require("../../utils/versions");
7
6
  const logger_1 = require("nx/src/utils/logger");
8
7
  const package_json_1 = require("nx/src/utils/package-json");
9
8
  function pluginLintCheckGenerator(host, options) {
@@ -29,11 +28,9 @@ function pluginLintCheckGenerator(host, options) {
29
28
  else {
30
29
  devkit_1.logger.error(`${logger_1.NX_PREFIX} plugin lint checks can only be added to plugins which use eslint for linting`);
31
30
  }
32
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, { 'jsonc-eslint-parser': versions_1.jsoncEslintParserVersion });
33
31
  if (!options.skipFormat) {
34
32
  yield (0, devkit_1.formatFiles)(host);
35
33
  }
36
- return () => installTask;
37
34
  });
38
35
  }
39
36
  exports.default = pluginLintCheckGenerator;
@@ -174,7 +171,7 @@ function setupVsCodeLintingForJsonFiles(host) {
174
171
  existing = (0, devkit_1.readJson)(host, '.vscode/settings.json');
175
172
  }
176
173
  else {
177
- devkit_1.logger.info(`${logger_1.NX_PREFIX} We've updated the vscode settings for this repository to ensure that plugin lint checks show up inside your IDE. This created .vscode/settings.json. To read more about this file, check vscode's documentation. It is frequently not commited, so other developers may need to add similar settings if they'd like to see the lint checks in the IDE rather than only during linting.`);
174
+ devkit_1.logger.info(`${logger_1.NX_PREFIX} We've updated the vscode settings for this repository to ensure that plugin lint checks show up inside your IDE. This created .vscode/settings.json. To read more about this file, check vscode's documentation. It is frequently not committed, so other developers may need to add similar settings if they'd like to see the lint checks in the IDE rather than only during linting.`);
178
175
  }
179
176
  // setup eslint validation for json files
180
177
  const eslintValidate = (_a = existing['eslint.validate']) !== null && _a !== void 0 ? _a : [];
@@ -1,6 +1,5 @@
1
1
  export * from './async-commands';
2
2
  export * from './commands';
3
- export * from './create-package-cli';
4
3
  export * from './paths';
5
4
  export * from './nx-project';
6
5
  export * from './utils';
@@ -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;