@nx/plugin 16.0.0-beta.5

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.
Files changed (132) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +22 -0
  3. package/README.md +67 -0
  4. package/executors.json +16 -0
  5. package/generators.d.ts +6 -0
  6. package/generators.js +10 -0
  7. package/generators.js.map +1 -0
  8. package/generators.json +81 -0
  9. package/index.d.ts +0 -0
  10. package/index.js +1 -0
  11. package/index.js.map +1 -0
  12. package/migrations.json +46 -0
  13. package/package.json +45 -0
  14. package/src/executors/e2e/compat.d.ts +1 -0
  15. package/src/executors/e2e/compat.js +7 -0
  16. package/src/executors/e2e/compat.js.map +1 -0
  17. package/src/executors/e2e/e2e.impl.d.ts +7 -0
  18. package/src/executors/e2e/e2e.impl.js +81 -0
  19. package/src/executors/e2e/e2e.impl.js.map +1 -0
  20. package/src/executors/e2e/schema.d.ts +6 -0
  21. package/src/executors/e2e/schema.json +220 -0
  22. package/src/generators/create-package/create-package.d.ts +5 -0
  23. package/src/generators/create-package/create-package.js +115 -0
  24. package/src/generators/create-package/create-package.js.map +1 -0
  25. package/src/generators/create-package/files/create-framework-package/bin/index.ts__tmpl__ +26 -0
  26. package/src/generators/create-package/files/e2e/__name__.spec.ts__tmpl__ +30 -0
  27. package/src/generators/create-package/schema.d.ts +17 -0
  28. package/src/generators/create-package/schema.json +69 -0
  29. package/src/generators/create-package/utils/normalize-schema.d.ts +10 -0
  30. package/src/generators/create-package/utils/normalize-schema.js +22 -0
  31. package/src/generators/create-package/utils/normalize-schema.js.map +1 -0
  32. package/src/generators/e2e-project/e2e.d.ts +6 -0
  33. package/src/generators/e2e-project/e2e.js +107 -0
  34. package/src/generators/e2e-project/e2e.js.map +1 -0
  35. package/src/generators/e2e-project/files/tests/__pluginName__.spec.ts__tmpl__ +37 -0
  36. package/src/generators/e2e-project/files/tsconfig.json__tmpl__ +6 -0
  37. package/src/generators/e2e-project/schema.d.ts +12 -0
  38. package/src/generators/e2e-project/schema.json +57 -0
  39. package/src/generators/executor/executor.d.ts +6 -0
  40. package/src/generators/executor/executor.js +104 -0
  41. package/src/generators/executor/executor.js.map +1 -0
  42. package/src/generators/executor/files/executor/__fileName__/executor.spec.ts__tmpl__ +11 -0
  43. package/src/generators/executor/files/executor/__fileName__/executor.ts__tmpl__ +11 -0
  44. package/src/generators/executor/files/executor/__fileName__/schema.d.ts__tmpl__ +1 -0
  45. package/src/generators/executor/files/executor/__fileName__/schema.json__tmpl__ +9 -0
  46. package/src/generators/executor/files/hasher/__fileName__/hasher.spec.ts__tmpl__ +22 -0
  47. package/src/generators/executor/files/hasher/__fileName__/hasher.ts__tmpl__ +12 -0
  48. package/src/generators/executor/schema.d.ts +9 -0
  49. package/src/generators/executor/schema.json +64 -0
  50. package/src/generators/generator/files/generator/__fileName__/generator.spec.ts__tmpl__ +20 -0
  51. package/src/generators/generator/files/generator/__fileName__/generator.ts__tmpl__ +72 -0
  52. package/src/generators/generator/files/generator/__fileName__/schema.d.ts__tmpl__ +5 -0
  53. package/src/generators/generator/files/generator/__fileName__/schema.json__tmpl__ +27 -0
  54. package/src/generators/generator/generator.d.ts +6 -0
  55. package/src/generators/generator/generator.js +106 -0
  56. package/src/generators/generator/generator.js.map +1 -0
  57. package/src/generators/generator/schema.d.ts +8 -0
  58. package/src/generators/generator/schema.json +60 -0
  59. package/src/generators/lint-checks/generator.d.ts +7 -0
  60. package/src/generators/lint-checks/generator.js +187 -0
  61. package/src/generators/lint-checks/generator.js.map +1 -0
  62. package/src/generators/lint-checks/schema.d.ts +4 -0
  63. package/src/generators/lint-checks/schema.json +25 -0
  64. package/src/generators/migration/files/migration/__name__/__name__.spec.ts__tmpl__ +17 -0
  65. package/src/generators/migration/files/migration/__name__/__name__.ts__tmpl__ +6 -0
  66. package/src/generators/migration/migration.d.ts +5 -0
  67. package/src/generators/migration/migration.js +111 -0
  68. package/src/generators/migration/migration.js.map +1 -0
  69. package/src/generators/migration/schema.d.ts +8 -0
  70. package/src/generators/migration/schema.json +59 -0
  71. package/src/generators/plugin/files/plugin/src/index.ts__tmpl__ +0 -0
  72. package/src/generators/plugin/plugin.d.ts +5 -0
  73. package/src/generators/plugin/plugin.js +95 -0
  74. package/src/generators/plugin/plugin.js.map +1 -0
  75. package/src/generators/plugin/schema.d.ts +17 -0
  76. package/src/generators/plugin/schema.json +93 -0
  77. package/src/generators/plugin/utils/normalize-schema.d.ts +14 -0
  78. package/src/generators/plugin/utils/normalize-schema.js +31 -0
  79. package/src/generators/plugin/utils/normalize-schema.js.map +1 -0
  80. package/src/generators/preset/generator.d.ts +3 -0
  81. package/src/generators/preset/generator.js +53 -0
  82. package/src/generators/preset/generator.js.map +1 -0
  83. package/src/generators/preset/schema.d.ts +4 -0
  84. package/src/generators/preset/schema.json +20 -0
  85. package/src/migrations/update-14-1-9/add-swc-deps-if-needed.d.ts +2 -0
  86. package/src/migrations/update-14-1-9/add-swc-deps-if-needed.js +14 -0
  87. package/src/migrations/update-14-1-9/add-swc-deps-if-needed.js.map +1 -0
  88. package/src/migrations/update-15-0-0/specify-output-capture.d.ts +2 -0
  89. package/src/migrations/update-15-0-0/specify-output-capture.js +57 -0
  90. package/src/migrations/update-15-0-0/specify-output-capture.js.map +1 -0
  91. package/src/migrations/update-15-9-0/jest-29-configs.d.ts +3 -0
  92. package/src/migrations/update-15-9-0/jest-29-configs.js +154 -0
  93. package/src/migrations/update-15-9-0/jest-29-configs.js.map +1 -0
  94. package/src/migrations/update-15-9-0/jest-29-tests.d.ts +5 -0
  95. package/src/migrations/update-15-9-0/jest-29-tests.js +65 -0
  96. package/src/migrations/update-15-9-0/jest-29-tests.js.map +1 -0
  97. package/src/migrations/update-16-0-0/cli-in-schema-json.d.ts +3 -0
  98. package/src/migrations/update-16-0-0/cli-in-schema-json.js +84 -0
  99. package/src/migrations/update-16-0-0/cli-in-schema-json.js.map +1 -0
  100. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  101. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
  102. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
  103. package/src/utils/has-generator.d.ts +2 -0
  104. package/src/utils/has-generator.js +17 -0
  105. package/src/utils/has-generator.js.map +1 -0
  106. package/src/utils/testing-utils/async-commands.d.ts +28 -0
  107. package/src/utils/testing-utils/async-commands.js +51 -0
  108. package/src/utils/testing-utils/async-commands.js.map +1 -0
  109. package/src/utils/testing-utils/commands.d.ts +17 -0
  110. package/src/utils/testing-utils/commands.js +64 -0
  111. package/src/utils/testing-utils/commands.js.map +1 -0
  112. package/src/utils/testing-utils/create-package-cli.d.ts +18 -0
  113. package/src/utils/testing-utils/create-package-cli.js +53 -0
  114. package/src/utils/testing-utils/create-package-cli.js.map +1 -0
  115. package/src/utils/testing-utils/index.d.ts +6 -0
  116. package/src/utils/testing-utils/index.js +10 -0
  117. package/src/utils/testing-utils/index.js.map +1 -0
  118. package/src/utils/testing-utils/nx-project.d.ts +25 -0
  119. package/src/utils/testing-utils/nx-project.js +64 -0
  120. package/src/utils/testing-utils/nx-project.js.map +1 -0
  121. package/src/utils/testing-utils/paths.d.ts +15 -0
  122. package/src/utils/testing-utils/paths.js +33 -0
  123. package/src/utils/testing-utils/paths.js.map +1 -0
  124. package/src/utils/testing-utils/utils.d.ts +80 -0
  125. package/src/utils/testing-utils/utils.js +145 -0
  126. package/src/utils/testing-utils/utils.js.map +1 -0
  127. package/src/utils/versions.d.ts +1 -0
  128. package/src/utils/versions.js +5 -0
  129. package/src/utils/versions.js.map +1 -0
  130. package/testing.d.ts +1 -0
  131. package/testing.js +5 -0
  132. package/testing.js.map +1 -0
@@ -0,0 +1,220 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "title": "Nx Plugin Playground Target",
5
+ "description": "Creates a playground for a Nx Plugin.",
6
+ "cli": "nx",
7
+ "type": "object",
8
+ "properties": {
9
+ "target": {
10
+ "description": "The build target for the Nx Plugin project.",
11
+ "type": "string",
12
+ "x-priority": "important"
13
+ },
14
+ "jestConfig": {
15
+ "type": "string",
16
+ "description": "Jest config file.",
17
+ "x-completion-type": "file",
18
+ "x-completion-glob": "jest.config@(.js|.ts)",
19
+ "x-priority": "important"
20
+ },
21
+ "tsSpecConfig": {
22
+ "type": "string",
23
+ "description": "The tsconfig file for specs.",
24
+ "x-deprecated": "Use the `tsconfig` property for `ts-jest` in the e2e project `jest.config.js` file. It will be removed in the next major release.",
25
+ "x-completion-type": "file",
26
+ "x-completion-glob": "tsconfig.*.json",
27
+ "x-priority": "important"
28
+ },
29
+ "codeCoverage": {
30
+ "description": "Indicates that test coverage information should be collected and reported in the output. (https://jestjs.io/docs/cli#--coverageboolean)",
31
+ "type": "boolean",
32
+ "aliases": ["coverage"]
33
+ },
34
+ "config": {
35
+ "description": "The path to a Jest config file specifying how to find and execute tests. If no `rootDir` is set in the config, the directory containing the config file is assumed to be the `rootDir` for the project. This can also be a JSON-encoded value which Jest will use as configuration.",
36
+ "type": "string"
37
+ },
38
+ "clearCache": {
39
+ "description": "Deletes the Jest cache directory and then exits without running tests. Will delete Jest's default cache directory. _Note: clearing the cache will reduce performance_.",
40
+ "type": "boolean"
41
+ },
42
+ "detectOpenHandles": {
43
+ "description": "Attempt to collect and print open handles preventing Jest from exiting cleanly (https://jestjs.io/docs/cli#--detectopenhandles)",
44
+ "type": "boolean"
45
+ },
46
+ "logHeapUsage": {
47
+ "description": "Logs the heap usage after every test. Useful to debug memory leaks. Use together with --runInBand and --expose-gc in node.",
48
+ "type": "boolean"
49
+ },
50
+ "detectLeaks": {
51
+ "description": "**EXPERIMENTAL**: Detect memory leaks in tests. After executing a test, it will try to garbage collect the global object used, and fail if it was leaked",
52
+ "type": "boolean"
53
+ },
54
+ "testFile": {
55
+ "description": "The name of the file to test.",
56
+ "type": "string",
57
+ "x-completion-type": "file",
58
+ "x-completion-glob": "**/*.+(spec|test).+(ts|js)"
59
+ },
60
+ "tsConfig": {
61
+ "description": "The name of the Typescript configuration file. Set the tsconfig option in the jest config file. ",
62
+ "type": "string",
63
+ "x-deprecated": "Use the ts-jest configuration options in the jest config file instead."
64
+ },
65
+ "setupFile": {
66
+ "description": "The name of a setup file used by Jest. (use Jest config file https://jestjs.io/docs/en/configuration#setupfilesafterenv-array)",
67
+ "type": "string",
68
+ "x-deprecated": "Use the setupFilesAfterEnv option in the jest config file. https://jestjs.io/docs/en/configuration#setupfilesafterenv-array"
69
+ },
70
+ "bail": {
71
+ "alias": "b",
72
+ "description": "Exit the test suite immediately after `n` number of failing tests. (https://jestjs.io/docs/cli#--bail)",
73
+ "oneOf": [
74
+ {
75
+ "type": "number"
76
+ },
77
+ {
78
+ "type": "boolean"
79
+ }
80
+ ]
81
+ },
82
+ "ci": {
83
+ "description": "Whether to run Jest in continuous integration (CI) mode. This option is on by default in most popular CI environments. It will prevent snapshots from being written unless explicitly requested. (https://jestjs.io/docs/cli#--ci)",
84
+ "type": "boolean"
85
+ },
86
+ "color": {
87
+ "alias": "colors",
88
+ "description": "Forces test results output color highlighting (even if `stdout` is not a TTY). Set to false if you would like to have no colors. (https://jestjs.io/docs/cli#--colors)",
89
+ "type": "boolean"
90
+ },
91
+ "findRelatedTests": {
92
+ "description": "Find and run the tests that cover a comma separated list of source files that were passed in as arguments. (https://jestjs.io/docs/cli#--findrelatedtests-spaceseparatedlistofsourcefiles)",
93
+ "type": "string"
94
+ },
95
+ "json": {
96
+ "description": "Prints the test results in `JSON`. This mode will send all other test output and user messages to `stderr`. (https://jestjs.io/docs/cli#--json)",
97
+ "type": "boolean"
98
+ },
99
+ "maxWorkers": {
100
+ "alias": "w",
101
+ "description": "Specifies the maximum number of workers the worker-pool will spawn for running tests. This defaults to the number of the cores available on your machine. Useful for CI. (its usually best not to override this default) (https://jestjs.io/docs/cli#--maxworkersnumstring)",
102
+ "oneOf": [
103
+ {
104
+ "type": "number"
105
+ },
106
+ {
107
+ "type": "string"
108
+ }
109
+ ]
110
+ },
111
+ "onlyChanged": {
112
+ "alias": "o",
113
+ "description": "Attempts to identify which tests to run based on which files have changed in the current repository. Only works if you're running tests in a `git` or `hg` repository at the moment. (https://jestjs.io/docs/cli#--onlychanged)",
114
+ "type": "boolean"
115
+ },
116
+ "changedSince": {
117
+ "description": "Runs tests related to the changes since the provided branch or commit hash. If the current branch has diverged from the given branch, then only changes made locally will be tested. (https://jestjs.io/docs/cli#--changedsince)",
118
+ "type": "string"
119
+ },
120
+ "outputFile": {
121
+ "description": "Write test results to a file when the `--json` option is also specified. (https://jestjs.io/docs/cli#--outputfilefilename)",
122
+ "type": "string"
123
+ },
124
+ "passWithNoTests": {
125
+ "description": "Will not fail if no tests are found (for example while using `--testPathPattern`.) (https://jestjs.io/docs/cli#--passwithnotests)",
126
+ "type": "boolean"
127
+ },
128
+ "runInBand": {
129
+ "alias": "i",
130
+ "description": "Run all tests serially in the current process (rather than creating a worker pool of child processes that run tests). This is sometimes useful for debugging, but such use cases are pretty rare. Useful for CI. (https://jestjs.io/docs/cli#--runinband)",
131
+ "type": "boolean",
132
+ "default": true
133
+ },
134
+ "showConfig": {
135
+ "description": "Print your Jest config and then exits. (https://jestjs.io/docs/en/cli#--showconfig)",
136
+ "type": "boolean"
137
+ },
138
+ "silent": {
139
+ "description": "Prevent tests from printing messages through the console. (https://jestjs.io/docs/cli#--silent)",
140
+ "type": "boolean"
141
+ },
142
+ "testNamePattern": {
143
+ "alias": "t",
144
+ "description": "Run only tests with a name that matches the regex pattern. (https://jestjs.io/docs/cli#--testnamepatternregex)",
145
+ "type": "string"
146
+ },
147
+ "testPathIgnorePatterns": {
148
+ "description": "An array of regexp pattern strings that is matched against all tests paths before executing the test. Only run those tests with a path that does not match with the provided regexp expressions. (https://jestjs.io/docs/cli#--testpathignorepatternsregexarray)",
149
+ "type": "array",
150
+ "items": {
151
+ "type": "string"
152
+ }
153
+ },
154
+ "testPathPattern": {
155
+ "description": "An array of regexp pattern strings that is matched against all tests paths before executing the test. (https://jestjs.io/docs/cli#--testpathpatternregex)",
156
+ "type": "array",
157
+ "items": {
158
+ "type": "string"
159
+ },
160
+ "default": []
161
+ },
162
+ "colors": {
163
+ "description": "Forces test results output highlighting even if stdout is not a TTY. (https://jestjs.io/docs/cli#--colors)",
164
+ "type": "boolean"
165
+ },
166
+ "reporters": {
167
+ "description": "Run tests with specified reporters. Reporter options are not available via CLI. Example with multiple reporters: `jest --reporters=\"default\" --reporters=\"jest-junit\"`. (https://jestjs.io/docs/cli#--reporters)",
168
+ "type": "array",
169
+ "items": {
170
+ "type": "string"
171
+ }
172
+ },
173
+ "verbose": {
174
+ "description": "Display individual test results with the test suite hierarchy. (https://jestjs.io/docs/cli#--verbose)",
175
+ "type": "boolean"
176
+ },
177
+ "coverageReporters": {
178
+ "description": "A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter.",
179
+ "type": "array",
180
+ "items": {
181
+ "type": "string"
182
+ }
183
+ },
184
+ "coverageDirectory": {
185
+ "description": "The directory where Jest should output its coverage files.",
186
+ "type": "string"
187
+ },
188
+ "testResultsProcessor": {
189
+ "description": "Node module that implements a custom results processor. (https://jestjs.io/docs/en/configuration#testresultsprocessor-string)",
190
+ "type": "string"
191
+ },
192
+ "updateSnapshot": {
193
+ "alias": "u",
194
+ "description": "Use this flag to re-record snapshots. Can be used together with a test suite pattern or with `--testNamePattern` to re-record snapshot for test matching the pattern. (https://jestjs.io/docs/cli#--updatesnapshot)",
195
+ "type": "boolean"
196
+ },
197
+ "useStderr": {
198
+ "description": "Divert all output to stderr.",
199
+ "type": "boolean"
200
+ },
201
+ "watch": {
202
+ "description": "Watch files for changes and rerun tests related to changed files. If you want to re-run all tests when a file has changed, use the `--watchAll` option. (https://jestjs.io/docs/cli#--watch)",
203
+ "type": "boolean"
204
+ },
205
+ "watchAll": {
206
+ "description": "Watch files for changes and rerun all tests when something changes. If you want to re-run only the tests that depend on the changed files, use the `--watch` option. (https://jestjs.io/docs/cli#--watchall)",
207
+ "type": "boolean"
208
+ },
209
+ "testLocationInResults": {
210
+ "description": "Adds a location field to test results. Used to report location of a test in a reporter. { \"column\": 4, \"line\": 5 } (https://jestjs.io/docs/cli#--testlocationinresults)",
211
+ "type": "boolean"
212
+ },
213
+ "testTimeout": {
214
+ "description": "Default timeout of a test in milliseconds. Default value: `5000`. (https://jestjs.io/docs/cli#--testtimeoutnumber)",
215
+ "type": "number"
216
+ }
217
+ },
218
+ "additionalProperties": false,
219
+ "required": ["target", "jestConfig"]
220
+ }
@@ -0,0 +1,5 @@
1
+ import { Tree, GeneratorCallback } from '@nx/devkit';
2
+ import { CreatePackageSchema } from './schema';
3
+ export declare function createPackageGenerator(host: Tree, schema: CreatePackageSchema): Promise<GeneratorCallback>;
4
+ export default createPackageGenerator;
5
+ export declare const createPackageSchematic: (generatorOptions: CreatePackageSchema) => (tree: any, context: any) => Promise<any>;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPackageSchematic = exports.createPackageGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const js_1 = require("@nx/js");
7
+ const versions_1 = require("nx/src/utils/versions");
8
+ const generator_1 = require("../generator/generator");
9
+ const normalize_schema_1 = require("./utils/normalize-schema");
10
+ const e2e_1 = require("../e2e-project/e2e");
11
+ const has_generator_1 = require("../../utils/has-generator");
12
+ function createPackageGenerator(host, schema) {
13
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
+ const tasks = [];
15
+ const options = (0, normalize_schema_1.normalizeSchema)(host, schema);
16
+ const pluginPackageName = yield addPresetGenerator(host, options);
17
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {
18
+ 'create-nx-workspace': versions_1.nxVersion,
19
+ }, {});
20
+ tasks.push(installTask);
21
+ yield createCliPackage(host, options, pluginPackageName);
22
+ if (options.e2eTestRunner !== 'none') {
23
+ tasks.push(yield addE2eProject(host, options));
24
+ }
25
+ if (!options.skipFormat) {
26
+ yield (0, devkit_1.formatFiles)(host);
27
+ }
28
+ return (0, devkit_1.runTasksInSerial)(...tasks);
29
+ });
30
+ }
31
+ exports.createPackageGenerator = createPackageGenerator;
32
+ /**
33
+ * Add a preset generator to the plugin if it doesn't exist
34
+ * @param host
35
+ * @param schema
36
+ * @returns package name of the plugin
37
+ */
38
+ function addPresetGenerator(host, schema) {
39
+ var _a;
40
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
+ const { root: projectRoot } = (0, devkit_1.readProjectConfiguration)(host, schema.project);
42
+ if (!(0, has_generator_1.hasGenerator)(host, schema.project, 'preset')) {
43
+ yield (0, generator_1.default)(host, {
44
+ name: 'preset',
45
+ project: schema.project,
46
+ unitTestRunner: schema.unitTestRunner,
47
+ skipFormat: true,
48
+ });
49
+ }
50
+ return (_a = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))) === null || _a === void 0 ? void 0 : _a.name;
51
+ });
52
+ }
53
+ function createCliPackage(host, options, pluginPackageName) {
54
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
55
+ yield (0, js_1.libraryGenerator)(host, Object.assign(Object.assign({}, options), { rootProject: false, config: 'project', publishable: true, bundler: options.bundler, importPath: options.name, skipFormat: true, skipTsConfig: true }));
56
+ host.delete((0, devkit_1.joinPathFragments)(options.projectRoot, 'src'));
57
+ // Add the bin entry to the package.json
58
+ (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), (packageJson) => {
59
+ packageJson.bin = {
60
+ [options.name]: './bin/index.js',
61
+ };
62
+ packageJson.dependencies = {
63
+ 'create-nx-workspace': versions_1.nxVersion,
64
+ };
65
+ return packageJson;
66
+ });
67
+ // update project build target to use the bin entry
68
+ const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
69
+ projectConfiguration.sourceRoot = (0, devkit_1.joinPathFragments)(options.projectRoot, 'bin');
70
+ projectConfiguration.targets.build.options.main = (0, devkit_1.joinPathFragments)(options.projectRoot, 'bin/index.ts');
71
+ projectConfiguration.targets.build.options.updateBuildableProjectDepsInPackageJson =
72
+ false;
73
+ projectConfiguration.implicitDependencies = [options.project];
74
+ (0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfiguration);
75
+ // Add bin files to tsconfg.lib.json
76
+ (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'), (tsConfig) => {
77
+ tsConfig.include.push('bin/**/*.ts');
78
+ return tsConfig;
79
+ });
80
+ (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/create-framework-package'), options.projectRoot, Object.assign(Object.assign({}, options), { preset: pluginPackageName, tmpl: '' }));
81
+ });
82
+ }
83
+ /**
84
+ * Add a test file to plugin e2e project
85
+ * @param host
86
+ * @param options
87
+ * @returns
88
+ */
89
+ function addE2eProject(host, options) {
90
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
91
+ const pluginProjectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.project);
92
+ const pluginOutputPath = pluginProjectConfiguration.targets.build.options.outputPath;
93
+ const cliProjectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
94
+ const cliOutputPath = cliProjectConfiguration.targets.build.options.outputPath;
95
+ const e2eTask = yield (0, e2e_1.default)(host, {
96
+ pluginName: options.projectName,
97
+ projectDirectory: options.projectDirectory,
98
+ pluginOutputPath,
99
+ npmPackageName: options.name,
100
+ skipFormat: true,
101
+ rootProject: false,
102
+ });
103
+ const e2eProjectConfiguration = (0, devkit_1.readProjectConfiguration)(host, `${options.projectName}-e2e`);
104
+ e2eProjectConfiguration.targets.e2e.dependsOn = ['^build'];
105
+ (0, devkit_1.updateProjectConfiguration)(host, e2eProjectConfiguration.name, e2eProjectConfiguration);
106
+ // delete the default e2e test file
107
+ host.delete(e2eProjectConfiguration.sourceRoot);
108
+ (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/e2e'), e2eProjectConfiguration.sourceRoot, Object.assign(Object.assign({}, options), { pluginOutputPath,
109
+ cliOutputPath, tmpl: '' }));
110
+ return e2eTask;
111
+ });
112
+ }
113
+ exports.default = createPackageGenerator;
114
+ exports.createPackageSchematic = (0, devkit_1.convertNxGenerator)(createPackageGenerator);
115
+ //# sourceMappingURL=create-package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-package.js","sourceRoot":"","sources":["../../../../../../packages/plugin/src/generators/create-package/create-package.ts"],"names":[],"mappings":";;;;AAAA,uCAaoB;AACpB,+BAAgE;AAChE,oDAAkD;AAClD,sDAAwD;AAExD,+DAA6E;AAC7E,4CAAqD;AACrD,6DAAyD;AAEzD,SAAsB,sBAAsB,CAC1C,IAAU,EACV,MAA2B;;QAE3B,MAAM,KAAK,GAAwB,EAAE,CAAC;QAEtC,MAAM,OAAO,GAAG,IAAA,kCAAe,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,iBAAiB,GAAG,MAAM,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAElE,MAAM,WAAW,GAAG,IAAA,qCAA4B,EAC9C,IAAI,EACJ;YACE,qBAAqB,EAAE,oBAAS;SACjC,EACD,EAAE,CACH,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAExB,MAAM,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACzD,IAAI,OAAO,CAAC,aAAa,KAAK,MAAM,EAAE;YACpC,KAAK,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;SAChD;QAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAA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sBAAsB,GAAG,IAAA,2BAAkB,EACtD,sBAAsB,CACvB,CAAC"}
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { createWorkspace } from 'create-nx-workspace';
4
+
5
+ async function main() {
6
+ const name = process.argv[2]; // TODO: use libraries like yargs or enquirer to set your workspace name
7
+ if (!name) {
8
+ throw new Error('Please provide a name for the workspace');
9
+ }
10
+
11
+ console.log(`Creating the workspace: ${name}`);
12
+
13
+ // TODO: update below to customize the workspace
14
+ const { directory } = await createWorkspace('<%= preset %>', {
15
+ name,
16
+ nxCloud: false,
17
+ packageManager: 'npm',
18
+ // This assumes "<%= preset %>" and "<%= projectName %>" are at the same version
19
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
20
+ presetVersion: require('../package.json').version,
21
+ });
22
+
23
+ console.log(`Successfully created the workspace: ${directory}.`);
24
+ }
25
+
26
+ main();
@@ -0,0 +1,30 @@
1
+ import {
2
+ uniq,
3
+ runCreatePackageCli,
4
+ removeTmpProject,
5
+ } from '@nx/plugin/testing';
6
+
7
+ describe('<%= name %> e2e', () => {
8
+ const project = uniq('<%= name %>');
9
+ let createPackageResult;
10
+
11
+ beforeAll(async () => {
12
+ // Create project using CLI command
13
+ createPackageResult = await runCreatePackageCli(
14
+ project,
15
+ {
16
+ pluginLibraryBuildPath: '<%= pluginOutputPath %>',
17
+ createPackageLibraryBuildPath: '<%= cliOutputPath %>',
18
+ }
19
+ );
20
+ }, 240_000);
21
+
22
+ afterAll(() => {
23
+ // Remove the generated project from the file system
24
+ removeTmpProject(project);
25
+ });
26
+
27
+ it('should create project using <%= name %>', () => {
28
+ expect(createPackageResult).toContain('Successfully created');
29
+ });
30
+ });
@@ -0,0 +1,17 @@
1
+ import type { Linter } from '@nx/linter';
2
+
3
+ export interface CreatePackageSchema {
4
+ name: string;
5
+ project: string;
6
+
7
+ // options to create cli package, passed to js library generator
8
+ directory?: string;
9
+ skipFormat: boolean;
10
+ tags?: string;
11
+ unitTestRunner: 'jest' | 'none';
12
+ linter: Linter;
13
+ compiler: 'swc' | 'tsc';
14
+
15
+ // options to create e2e project, passed to e2e project generator
16
+ e2eTestRunner?: 'jest' | 'none';
17
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NxPluginCreatePackage",
5
+ "title": "Create a framework package",
6
+ "description": "Create a framework package that uses Nx CLI.",
7
+ "type": "object",
8
+ "properties": {
9
+ "name": {
10
+ "type": "string",
11
+ "description": "The package name of cli, e.g. `create-framework-package`. Note this must be a valid NPM name to be published.",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-priority": "important"
17
+ },
18
+ "project": {
19
+ "type": "string",
20
+ "description": "The name of the generator project.",
21
+ "alias": "p",
22
+ "$default": {
23
+ "$source": "projectName"
24
+ },
25
+ "x-prompt": "What is the name of the project for the generator?",
26
+ "x-priority": "important"
27
+ },
28
+ "unitTestRunner": {
29
+ "type": "string",
30
+ "enum": ["jest", "none"],
31
+ "description": "Test runner to use for unit tests.",
32
+ "default": "jest"
33
+ },
34
+ "directory": {
35
+ "type": "string",
36
+ "description": "A directory where the app is placed."
37
+ },
38
+ "linter": {
39
+ "description": "The tool to use for running lint checks.",
40
+ "type": "string",
41
+ "enum": ["eslint"],
42
+ "default": "eslint"
43
+ },
44
+ "tags": {
45
+ "type": "string",
46
+ "description": "Add tags to the library (used for linting).",
47
+ "alias": "t"
48
+ },
49
+ "skipFormat": {
50
+ "description": "Skip formatting files.",
51
+ "type": "boolean",
52
+ "default": false,
53
+ "x-priority": "internal"
54
+ },
55
+ "compiler": {
56
+ "type": "string",
57
+ "enum": ["tsc", "swc"],
58
+ "default": "tsc",
59
+ "description": "The compiler used by the build and test targets."
60
+ },
61
+ "e2eTestRunner": {
62
+ "type": "string",
63
+ "enum": ["jest", "none"],
64
+ "description": "Test runner to use for end to end (E2E) tests.",
65
+ "default": "jest"
66
+ }
67
+ },
68
+ "required": ["name", "project"]
69
+ }
@@ -0,0 +1,10 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { CreatePackageSchema } from '../schema';
3
+ export interface NormalizedSchema extends CreatePackageSchema {
4
+ bundler: 'swc' | 'tsc';
5
+ libsDir: string;
6
+ projectName: string;
7
+ projectRoot: string;
8
+ projectDirectory: string;
9
+ }
10
+ export declare function normalizeSchema(host: Tree, schema: CreatePackageSchema): NormalizedSchema;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeSchema = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function normalizeSchema(host, schema) {
6
+ var _a;
7
+ const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(schema.directory);
8
+ const { libsDir: defaultLibsDir } = (0, devkit_1.getWorkspaceLayout)(host);
9
+ const libsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : defaultLibsDir;
10
+ const name = (0, devkit_1.names)(schema.name).fileName;
11
+ const fullProjectDirectory = projectDirectory
12
+ ? `${(0, devkit_1.names)(projectDirectory).fileName}/${name}`
13
+ : name;
14
+ const projectName = fullProjectDirectory.replace(new RegExp('/', 'g'), '-');
15
+ const projectRoot = (0, devkit_1.joinPathFragments)(libsDir, fullProjectDirectory);
16
+ return Object.assign(Object.assign({}, schema), { bundler: (_a = schema.compiler) !== null && _a !== void 0 ? _a : 'tsc', libsDir,
17
+ projectName,
18
+ projectRoot,
19
+ name, projectDirectory: fullProjectDirectory });
20
+ }
21
+ exports.normalizeSchema = normalizeSchema;
22
+ //# sourceMappingURL=normalize-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-schema.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/src/generators/create-package/utils/normalize-schema.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AAWpB,SAAgB,eAAe,CAC7B,IAAU,EACV,MAA2B;;IAE3B,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,GAAG,IAAA,+BAAsB,EAClE,MAAM,CAAC,SAAS,CACjB,CAAC;IACF,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,cAAc,CAAC;IAClD,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IACzC,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC,QAAQ,IAAI,IAAI,EAAE;QAC/C,CAAC,CAAC,IAAI,CAAC;IACT,MAAM,WAAW,GAAG,oBAAoB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5E,MAAM,WAAW,GAAG,IAAA,0BAAiB,EAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IACrE,uCACK,MAAM,KACT,OAAO,EAAE,MAAA,MAAM,CAAC,QAAQ,mCAAI,KAAK,EACjC,OAAO;QACP,WAAW;QACX,WAAW;QACX,IAAI,EACJ,gBAAgB,EAAE,oBAAoB,IACtC;AACJ,CAAC;AAxBD,0CAwBC"}
@@ -0,0 +1,6 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ import { GeneratorCallback } from '@nx/devkit';
3
+ import type { Schema } from './schema';
4
+ export declare function e2eProjectGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
5
+ export default e2eProjectGenerator;
6
+ export declare const e2eProjectSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.e2eProjectSchematic = exports.e2eProjectGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const jest_1 = require("@nx/jest");
7
+ const js_1 = require("@nx/js");
8
+ const path = require("path");
9
+ const linter_1 = require("@nx/linter");
10
+ function normalizeOptions(host, options) {
11
+ var _a;
12
+ const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.projectDirectory);
13
+ const { npmScope, appsDir: defaultAppsDir } = (0, devkit_1.getWorkspaceLayout)(host);
14
+ const appsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : defaultAppsDir;
15
+ const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
16
+ const projectRoot = projectDirectory && !options.rootProject
17
+ ? (0, devkit_1.joinPathFragments)(appsDir, `${projectDirectory}-e2e`)
18
+ : options.rootProject
19
+ ? projectName
20
+ : (0, devkit_1.joinPathFragments)(appsDir, projectName);
21
+ const pluginPropertyName = (0, devkit_1.names)(options.pluginName).propertyName;
22
+ 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
+ }
26
+ function validatePlugin(host, pluginName) {
27
+ try {
28
+ (0, devkit_1.readProjectConfiguration)(host, pluginName);
29
+ }
30
+ catch (_a) {
31
+ throw new Error(`Project name "${pluginName}" doesn't not exist.`);
32
+ }
33
+ }
34
+ 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
+ }
37
+ function updateWorkspaceConfiguration(host, options) {
38
+ (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
39
+ root: options.projectRoot,
40
+ projectType: 'application',
41
+ sourceRoot: `${options.projectRoot}/tests`,
42
+ targets: {
43
+ e2e: {
44
+ executor: '@nx/plugin:e2e',
45
+ options: { target: `${options.pluginName}:build` },
46
+ },
47
+ },
48
+ tags: [],
49
+ implicitDependencies: [options.pluginName],
50
+ });
51
+ }
52
+ function addJest(host, options) {
53
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
54
+ yield (0, jest_1.jestProjectGenerator)(host, {
55
+ project: options.projectName,
56
+ setupFile: 'none',
57
+ supportTsx: false,
58
+ skipSerializers: true,
59
+ skipFormat: true,
60
+ });
61
+ const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
62
+ const testOptions = project.targets.test.options;
63
+ const e2eOptions = project.targets.e2e.options;
64
+ project.targets.e2e.options = Object.assign(Object.assign({}, e2eOptions), { jestConfig: testOptions.jestConfig });
65
+ // remove the jest build target
66
+ delete project.targets.test;
67
+ (0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
68
+ });
69
+ }
70
+ function addLintingToApplication(tree, options) {
71
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
72
+ const lintTask = yield (0, linter_1.lintProjectGenerator)(tree, {
73
+ linter: options.linter,
74
+ project: options.projectName,
75
+ tsConfigPaths: [
76
+ (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
77
+ ],
78
+ eslintFilePatterns: [`${options.projectRoot}/**/*.ts`],
79
+ unitTestRunner: 'jest',
80
+ skipFormat: true,
81
+ setParserOptionsProject: false,
82
+ });
83
+ return lintTask;
84
+ });
85
+ }
86
+ function e2eProjectGenerator(host, schema) {
87
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
88
+ const tasks = [];
89
+ validatePlugin(host, schema.pluginName);
90
+ const options = normalizeOptions(host, schema);
91
+ addFiles(host, options);
92
+ updateWorkspaceConfiguration(host, options);
93
+ yield addJest(host, options);
94
+ if (options.linter !== linter_1.Linter.None) {
95
+ const lintTask = yield addLintingToApplication(host, Object.assign({}, options));
96
+ tasks.push(lintTask);
97
+ }
98
+ if (!options.skipFormat) {
99
+ yield (0, devkit_1.formatFiles)(host);
100
+ }
101
+ return (0, devkit_1.runTasksInSerial)(...tasks);
102
+ });
103
+ }
104
+ exports.e2eProjectGenerator = e2eProjectGenerator;
105
+ exports.default = e2eProjectGenerator;
106
+ exports.e2eProjectSchematic = (0, devkit_1.convertNxGenerator)(e2eProjectGenerator);
107
+ //# sourceMappingURL=e2e.js.map