@clipboard-health/nx-plugin 0.3.1 → 0.3.4
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/README.md +0 -2
- package/package.json +3 -2
- package/src/generators/node-lib/files/src/index.js +5 -0
- package/src/generators/node-lib/files/src/index.js.map +1 -0
- package/src/generators/node-lib/files/src/lib/rename-me.d.ts +1 -0
- package/src/generators/node-lib/files/src/lib/rename-me.js +7 -0
- package/src/generators/node-lib/files/src/lib/rename-me.js.map +1 -0
- package/src/generators/node-lib/generator.d.ts +3 -0
- package/src/generators/node-lib/generator.js +52 -0
- package/src/generators/node-lib/generator.js.map +1 -0
- package/src/generators/node-lib/schema.d.ts +1 -1
- package/src/generators/node-lib/schema.json +1 -1
- package/src/index.d.ts +0 -0
- package/src/{index.ts → index.js} +2 -0
- package/src/index.js.map +1 -0
- package/.eslintrc.json +0 -8
- package/jest.config.ts +0 -19
- package/project.json +0 -50
- package/src/generators/node-lib/files/src/lib/rename-me.spec.ts +0 -7
- package/src/generators/node-lib/files/src/lib/rename-me.ts +0 -3
- package/src/generators/node-lib/generator.spec.ts +0 -19
- package/src/generators/node-lib/generator.ts +0 -88
- package/tsconfig.json +0 -19
- package/tsconfig.lib.json +0 -9
- package/tsconfig.lint.json +0 -7
- package/tsconfig.spec.json +0 -7
- package/typedoc.json +0 -4
- /package/src/generators/node-lib/files/src/{index.ts → index.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -7,8 +7,6 @@ Clipboard Health's Nx plugin contains generators to manage libraries within an N
|
|
|
7
7
|
- [Table of Contents](#table-of-contents)
|
|
8
8
|
- [Install](#install)
|
|
9
9
|
- [Usage](#usage)
|
|
10
|
-
- [Adding new libraries](#adding-new-libraries)
|
|
11
|
-
- [Porting existing libraries](#porting-existing-libraries)
|
|
12
10
|
|
|
13
11
|
## Install
|
|
14
12
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clipboard-health/nx-plugin",
|
|
3
3
|
"description": "Clipboard Health's Nx plugin contains generators to manage applications within an Nx workspace.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.4",
|
|
5
5
|
"bugs": "https://github.com/clipboardhealth/core-utils/issues",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@nx/devkit": "19.5.6",
|
|
@@ -28,5 +28,6 @@
|
|
|
28
28
|
"directory": "packages/nx-plugin"
|
|
29
29
|
},
|
|
30
30
|
"type": "commonjs",
|
|
31
|
-
"typings": "./src/index.d.ts"
|
|
31
|
+
"typings": "./src/index.d.ts",
|
|
32
|
+
"types": "./src/index.d.ts"
|
|
32
33
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/nx-plugin/src/generators/node-lib/files/src/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deleteMe(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-me.js","sourceRoot":"","sources":["../../../../../../../../../packages/nx-plugin/src/generators/node-lib/files/src/lib/rename-me.ts"],"names":[],"mappings":";;AAAA,4BAEC;AAFD,SAAgB,QAAQ;IACtB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = generate;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
7
|
+
const ROOT_TS_CONFIG = "tsconfig.base.json";
|
|
8
|
+
function normalizeOptions(tree, options) {
|
|
9
|
+
const name = (0, devkit_1.names)(options.name).fileName;
|
|
10
|
+
const projectDirectory = name;
|
|
11
|
+
return {
|
|
12
|
+
...options,
|
|
13
|
+
publishConfigAccess: options.publishPublicly ? "public" : "restricted",
|
|
14
|
+
importPath: (0, get_import_path_1.getImportPath)(tree, projectDirectory),
|
|
15
|
+
projectName: name.replaceAll("/", "-"),
|
|
16
|
+
projectRoot: `${(0, devkit_1.getWorkspaceLayout)(tree).libsDir}/${name}`,
|
|
17
|
+
projectDirectory,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function getRelativePathToRootTsConfig(targetPath) {
|
|
21
|
+
return `${(0, devkit_1.offsetFromRoot)(targetPath)}${ROOT_TS_CONFIG}`;
|
|
22
|
+
}
|
|
23
|
+
function addFiles(tree, options) {
|
|
24
|
+
(0, devkit_1.generateFiles)(tree, (0, node_path_1.join)(__dirname, "files"), options.projectRoot, {
|
|
25
|
+
...options,
|
|
26
|
+
...(0, devkit_1.names)(options.name),
|
|
27
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
28
|
+
rootTsConfigPath: getRelativePathToRootTsConfig(options.projectRoot),
|
|
29
|
+
template: "",
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function updateRootTsConfig(host, options) {
|
|
33
|
+
(0, devkit_1.updateJson)(host, ROOT_TS_CONFIG, (json) => {
|
|
34
|
+
const c = json.compilerOptions;
|
|
35
|
+
c.paths ||= {};
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
37
|
+
delete c.paths[options.name];
|
|
38
|
+
/* istanbul ignore next */
|
|
39
|
+
if (c.paths[options.importPath]) {
|
|
40
|
+
throw new Error(`There is already a library with import path "${options.importPath}".`);
|
|
41
|
+
}
|
|
42
|
+
c.paths[options.importPath] = [(0, devkit_1.joinPathFragments)(options.projectRoot, "./src", "index.ts")];
|
|
43
|
+
return json;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async function generate(tree, options) {
|
|
47
|
+
const normalizedOptions = normalizeOptions(tree, options);
|
|
48
|
+
addFiles(tree, normalizedOptions);
|
|
49
|
+
updateRootTsConfig(tree, normalizedOptions);
|
|
50
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/generators/node-lib/generator.ts"],"names":[],"mappings":";;AAkFA,2BAKC;AAvFD,yCAAiC;AAEjC,uCASoB;AACpB,sEAAiE;AAIjE,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAU5C,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAAgC;IACpE,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,IAAI,CAAC;IAC9B,OAAO;QACL,GAAG,OAAO;QACV,mBAAmB,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY;QACtE,UAAU,EAAE,IAAA,+BAAa,EAAC,IAAI,EAAE,gBAAgB,CAAC;QACjD,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;QACtC,WAAW,EAAE,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,EAAE;QAC1D,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,6BAA6B,CAAC,UAAkB;IACvD,OAAO,GAAG,IAAA,uBAAc,EAAC,UAAU,CAAC,GAAG,cAAc,EAAE,CAAC;AAC1D,CAAC;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,OAAyB;IACrD,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,gBAAI,EAAC,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,EAAE;QACjE,GAAG,OAAO;QACV,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC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z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
17
|
+
"publishPublicly": {
|
|
18
18
|
"type": "boolean",
|
|
19
19
|
"default": false,
|
|
20
20
|
"description": "Publish the NPM package publicly.",
|
package/src/index.d.ts
ADDED
|
File without changes
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nx-plugin/src/index.ts"],"names":[],"mappings":";AAAA,iDAAiD"}
|
package/.eslintrc.json
DELETED
package/jest.config.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
coverageDirectory: "../../coverage/packages/nx-plugin",
|
|
3
|
-
coveragePathIgnorePatterns: [],
|
|
4
|
-
coverageThreshold: {
|
|
5
|
-
global: {
|
|
6
|
-
branches: 100,
|
|
7
|
-
functions: 100,
|
|
8
|
-
lines: 100,
|
|
9
|
-
statements: 100,
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
displayName: "nx-plugin",
|
|
13
|
-
moduleFileExtensions: ["ts", "js"],
|
|
14
|
-
preset: "../../jest.preset.js",
|
|
15
|
-
testEnvironment: "node",
|
|
16
|
-
transform: {
|
|
17
|
-
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }],
|
|
18
|
-
},
|
|
19
|
-
};
|
package/project.json
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
3
|
-
"name": "nx-plugin",
|
|
4
|
-
"projectType": "library",
|
|
5
|
-
"sourceRoot": "packages/nx-plugin/src",
|
|
6
|
-
"tags": [],
|
|
7
|
-
"targets": {
|
|
8
|
-
"build": {
|
|
9
|
-
"executor": "@nx/js:tsc",
|
|
10
|
-
"options": {
|
|
11
|
-
"assets": [
|
|
12
|
-
"packages/nx-plugin/*.md",
|
|
13
|
-
{
|
|
14
|
-
"input": "./packages/nx-plugin/src",
|
|
15
|
-
"glob": "**/!(*.ts)",
|
|
16
|
-
"output": "./src"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"input": "./packages/nx-plugin/src",
|
|
20
|
-
"glob": "**/*.d.ts",
|
|
21
|
-
"output": "./src"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"input": "./packages/nx-plugin",
|
|
25
|
-
"glob": "generators.json",
|
|
26
|
-
"output": "."
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"main": "packages/nx-plugin/src/index.ts",
|
|
30
|
-
"outputPath": "dist/packages/nx-plugin",
|
|
31
|
-
"tsConfig": "packages/nx-plugin/tsconfig.lib.json"
|
|
32
|
-
},
|
|
33
|
-
"outputs": ["{options.outputPath}"]
|
|
34
|
-
},
|
|
35
|
-
"lint": {
|
|
36
|
-
"executor": "@nx/eslint:lint",
|
|
37
|
-
"options": {
|
|
38
|
-
"maxWarnings": 0
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"test": {
|
|
42
|
-
"executor": "@nx/jest:jest",
|
|
43
|
-
"options": {
|
|
44
|
-
"jestConfig": "packages/nx-plugin/jest.config.ts",
|
|
45
|
-
"passWithNoTests": false
|
|
46
|
-
},
|
|
47
|
-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"]
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { readProjectConfiguration, type Tree } from "@nx/devkit";
|
|
2
|
-
import { createTreeWithEmptyWorkspace } from "@nx/devkit/testing";
|
|
3
|
-
|
|
4
|
-
import generator from "./generator";
|
|
5
|
-
|
|
6
|
-
describe("generator", () => {
|
|
7
|
-
let appTree: Tree;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
appTree = createTreeWithEmptyWorkspace({ layout: "apps-libs" });
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("runs successfully", async () => {
|
|
14
|
-
const name = "test";
|
|
15
|
-
await generator(appTree, { name });
|
|
16
|
-
const config = readProjectConfiguration(appTree, name);
|
|
17
|
-
expect(config).toBeDefined();
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
formatFiles,
|
|
5
|
-
generateFiles,
|
|
6
|
-
getWorkspaceLayout,
|
|
7
|
-
joinPathFragments,
|
|
8
|
-
names,
|
|
9
|
-
offsetFromRoot,
|
|
10
|
-
type Tree,
|
|
11
|
-
updateJson,
|
|
12
|
-
} from "@nx/devkit";
|
|
13
|
-
import { getImportPath } from "@nx/js/src/utils/get-import-path";
|
|
14
|
-
|
|
15
|
-
import type { NxPluginGeneratorSchema } from "./schema";
|
|
16
|
-
|
|
17
|
-
const ROOT_TS_CONFIG = "tsconfig.base.json";
|
|
18
|
-
|
|
19
|
-
type NormalizedSchema = NxPluginGeneratorSchema & {
|
|
20
|
-
importPath: string;
|
|
21
|
-
projectName: string;
|
|
22
|
-
projectRoot: string;
|
|
23
|
-
projectDirectory: string;
|
|
24
|
-
publishConfigAccess: string;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function normalizeOptions(tree: Tree, options: NxPluginGeneratorSchema): NormalizedSchema {
|
|
28
|
-
const name = names(options.name).fileName;
|
|
29
|
-
const projectDirectory = name;
|
|
30
|
-
return {
|
|
31
|
-
...options,
|
|
32
|
-
publishConfigAccess: options.publishConfigPublicAccess ? "public" : "restricted",
|
|
33
|
-
importPath: getImportPath(tree, projectDirectory),
|
|
34
|
-
projectName: name.replaceAll("/", "-"),
|
|
35
|
-
projectRoot: `${getWorkspaceLayout(tree).libsDir}/${name}`,
|
|
36
|
-
projectDirectory,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function getRelativePathToRootTsConfig(targetPath: string): string {
|
|
41
|
-
return `${offsetFromRoot(targetPath)}${ROOT_TS_CONFIG}`;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function addFiles(tree: Tree, options: NormalizedSchema) {
|
|
45
|
-
generateFiles(tree, join(__dirname, "files"), options.projectRoot, {
|
|
46
|
-
...options,
|
|
47
|
-
...names(options.name),
|
|
48
|
-
offsetFromRoot: offsetFromRoot(options.projectRoot),
|
|
49
|
-
rootTsConfigPath: getRelativePathToRootTsConfig(options.projectRoot),
|
|
50
|
-
template: "",
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function updateRootTsConfig(
|
|
55
|
-
host: Tree,
|
|
56
|
-
options: {
|
|
57
|
-
name: string;
|
|
58
|
-
importPath: string;
|
|
59
|
-
projectRoot: string;
|
|
60
|
-
},
|
|
61
|
-
) {
|
|
62
|
-
updateJson<{ compilerOptions: { paths: Record<string, string[]> } }>(
|
|
63
|
-
host,
|
|
64
|
-
ROOT_TS_CONFIG,
|
|
65
|
-
(json) => {
|
|
66
|
-
const c = json.compilerOptions;
|
|
67
|
-
c.paths ||= {};
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
69
|
-
delete c.paths[options.name];
|
|
70
|
-
|
|
71
|
-
/* istanbul ignore next */
|
|
72
|
-
if (c.paths[options.importPath]) {
|
|
73
|
-
throw new Error(`There is already a library with import path "${options.importPath}".`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
c.paths[options.importPath] = [joinPathFragments(options.projectRoot, "./src", "index.ts")];
|
|
77
|
-
|
|
78
|
-
return json;
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export default async function generate(tree: Tree, options: NxPluginGeneratorSchema) {
|
|
84
|
-
const normalizedOptions = normalizeOptions(tree, options);
|
|
85
|
-
addFiles(tree, normalizedOptions);
|
|
86
|
-
updateRootTsConfig(tree, normalizedOptions);
|
|
87
|
-
await formatFiles(tree);
|
|
88
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc"
|
|
5
|
-
},
|
|
6
|
-
"files": [],
|
|
7
|
-
"include": [],
|
|
8
|
-
"references": [
|
|
9
|
-
{
|
|
10
|
-
"path": "./tsconfig.lib.json"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"path": "./tsconfig.lint.json"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"path": "./tsconfig.spec.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
package/tsconfig.lib.json
DELETED
package/tsconfig.lint.json
DELETED
package/tsconfig.spec.json
DELETED
package/typedoc.json
DELETED
|
File without changes
|