@storm-software/workspace-tools 1.290.10 → 1.291.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/CHANGELOG.md +29 -0
- package/README.md +1 -1
- package/dist/{chunk-MR2J2XDA.js → chunk-3WCQK76E.js} +22 -292
- package/dist/{chunk-KKCNNJUO.mjs → chunk-DVZPBLGA.mjs} +20 -290
- package/dist/chunk-F3NQOV2M.mjs +314 -0
- package/dist/chunk-FSYURQ5X.js +314 -0
- package/dist/chunk-H5NKQQJU.mjs +363 -0
- package/dist/chunk-OTI7QVPG.js +363 -0
- package/dist/executor-4s6Siy2o.d.ts +144 -0
- package/dist/executor-BmxxnfjA.d.mts +144 -0
- package/dist/executors.d.mts +1 -0
- package/dist/executors.d.ts +1 -0
- package/dist/executors.js +11 -6
- package/dist/executors.mjs +13 -8
- package/dist/generators.js +3 -3
- package/dist/generators.mjs +3 -3
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -9
- package/dist/index.mjs +16 -11
- package/dist/src/executors/esbuild/executor.js +3 -2
- package/dist/src/executors/esbuild/executor.mjs +2 -1
- package/dist/src/executors/tsdown/executor.d.mts +5 -0
- package/dist/src/executors/tsdown/executor.d.ts +5 -0
- package/dist/src/executors/tsdown/executor.js +15 -0
- package/dist/src/executors/tsdown/executor.mjs +16 -0
- package/dist/src/executors/tsdown/schema.d.ts +135 -0
- package/dist/src/executors/tsdown/schema.json +174 -0
- package/dist/src/executors/tsdown/untyped.d.mts +5 -0
- package/dist/src/executors/tsdown/untyped.d.ts +5 -0
- package/dist/src/executors/tsdown/untyped.js +18 -0
- package/dist/src/executors/tsdown/untyped.mjs +19 -0
- package/dist/src/plugins/typescript/tsdown.d.mts +9 -0
- package/dist/src/plugins/typescript/tsdown.d.ts +9 -0
- package/dist/src/plugins/typescript/tsdown.js +169 -0
- package/dist/src/plugins/typescript/tsdown.mjs +170 -0
- package/docs/api/executors/tsdown/schema.md +126 -0
- package/package.json +9 -7
- /package/dist/{chunk-7VDOGZYO.js → chunk-3J53KHVV.js} +0 -0
- /package/dist/{chunk-BLX5SLPC.mjs → chunk-V7YZ3666.mjs} +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "#",
|
|
3
|
+
"title": "TSDown Executor",
|
|
4
|
+
"description": "A type definition for an TSDown executor schema",
|
|
5
|
+
"properties": {
|
|
6
|
+
"outputPath": {
|
|
7
|
+
"title": "Output Path",
|
|
8
|
+
"type": "string",
|
|
9
|
+
"format": "path",
|
|
10
|
+
"description": "The output path for the build",
|
|
11
|
+
"id": "#outputPath",
|
|
12
|
+
"default": "dist/{projectRoot}"
|
|
13
|
+
},
|
|
14
|
+
"entry": {
|
|
15
|
+
"title": "Entry File(s)",
|
|
16
|
+
"format": "path",
|
|
17
|
+
"type": "array",
|
|
18
|
+
"description": "The entry file or files to build",
|
|
19
|
+
"items": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"id": "#entry",
|
|
23
|
+
"default": [
|
|
24
|
+
"{sourceRoot}/index.ts"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"tsconfig": {
|
|
28
|
+
"title": "TSConfig Path",
|
|
29
|
+
"type": "string",
|
|
30
|
+
"format": "path",
|
|
31
|
+
"description": "The path to the tsconfig file",
|
|
32
|
+
"id": "#tsconfig",
|
|
33
|
+
"default": "{projectRoot}/tsconfig.json"
|
|
34
|
+
},
|
|
35
|
+
"bundle": {
|
|
36
|
+
"title": "Bundle",
|
|
37
|
+
"type": "boolean",
|
|
38
|
+
"description": "Bundle the output",
|
|
39
|
+
"id": "#bundle"
|
|
40
|
+
},
|
|
41
|
+
"minify": {
|
|
42
|
+
"title": "Minify",
|
|
43
|
+
"type": "boolean",
|
|
44
|
+
"description": "Minify the output",
|
|
45
|
+
"id": "#minify"
|
|
46
|
+
},
|
|
47
|
+
"debug": {
|
|
48
|
+
"title": "Debug",
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"description": "Debug the output",
|
|
51
|
+
"id": "#debug"
|
|
52
|
+
},
|
|
53
|
+
"sourcemap": {
|
|
54
|
+
"title": "Sourcemap",
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"description": "Generate a sourcemap",
|
|
57
|
+
"id": "#sourcemap"
|
|
58
|
+
},
|
|
59
|
+
"silent": {
|
|
60
|
+
"title": "Silent",
|
|
61
|
+
"type": "boolean",
|
|
62
|
+
"description": "Should the build run silently - only report errors back to the user",
|
|
63
|
+
"id": "#silent",
|
|
64
|
+
"default": false
|
|
65
|
+
},
|
|
66
|
+
"target": {
|
|
67
|
+
"title": "Target",
|
|
68
|
+
"type": "string",
|
|
69
|
+
"description": "The target to build",
|
|
70
|
+
"enum": [
|
|
71
|
+
"es3",
|
|
72
|
+
"es5",
|
|
73
|
+
"es6",
|
|
74
|
+
"es2015",
|
|
75
|
+
"es2016",
|
|
76
|
+
"es2017",
|
|
77
|
+
"es2018",
|
|
78
|
+
"es2019",
|
|
79
|
+
"es2020",
|
|
80
|
+
"es2021",
|
|
81
|
+
"es2022",
|
|
82
|
+
"es2023",
|
|
83
|
+
"es2024",
|
|
84
|
+
"esnext",
|
|
85
|
+
"node12",
|
|
86
|
+
"node14",
|
|
87
|
+
"node16",
|
|
88
|
+
"node18",
|
|
89
|
+
"node20",
|
|
90
|
+
"node22",
|
|
91
|
+
"browser",
|
|
92
|
+
"chrome58",
|
|
93
|
+
"chrome59",
|
|
94
|
+
"chrome60"
|
|
95
|
+
],
|
|
96
|
+
"id": "#target",
|
|
97
|
+
"default": "esnext"
|
|
98
|
+
},
|
|
99
|
+
"format": {
|
|
100
|
+
"title": "Format",
|
|
101
|
+
"type": "array",
|
|
102
|
+
"description": "The format to build",
|
|
103
|
+
"items": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"enum": [
|
|
106
|
+
"cjs",
|
|
107
|
+
"esm",
|
|
108
|
+
"iife"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"id": "#format",
|
|
112
|
+
"default": [
|
|
113
|
+
"cjs",
|
|
114
|
+
"esm"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"platform": {
|
|
118
|
+
"title": "Platform",
|
|
119
|
+
"type": "string",
|
|
120
|
+
"description": "The platform to build",
|
|
121
|
+
"enum": [
|
|
122
|
+
"neutral",
|
|
123
|
+
"node",
|
|
124
|
+
"browser"
|
|
125
|
+
],
|
|
126
|
+
"id": "#platform",
|
|
127
|
+
"default": "neutral"
|
|
128
|
+
},
|
|
129
|
+
"external": {
|
|
130
|
+
"title": "External",
|
|
131
|
+
"type": "array",
|
|
132
|
+
"description": "The external dependencies",
|
|
133
|
+
"id": "#external",
|
|
134
|
+
"default": [],
|
|
135
|
+
"items": {
|
|
136
|
+
"type": "any"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"define": {
|
|
140
|
+
"title": "Define",
|
|
141
|
+
"type": "object",
|
|
142
|
+
"tsType": "Record<string, string>",
|
|
143
|
+
"description": "The define values",
|
|
144
|
+
"id": "#define",
|
|
145
|
+
"default": {}
|
|
146
|
+
},
|
|
147
|
+
"env": {
|
|
148
|
+
"title": "Environment Variables",
|
|
149
|
+
"type": "object",
|
|
150
|
+
"tsType": "Record<string, string>",
|
|
151
|
+
"description": "The environment variable values",
|
|
152
|
+
"id": "#env",
|
|
153
|
+
"default": {}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"type": "object",
|
|
157
|
+
"default": {
|
|
158
|
+
"outputPath": "dist/{projectRoot}",
|
|
159
|
+
"entry": [
|
|
160
|
+
"{sourceRoot}/index.ts"
|
|
161
|
+
],
|
|
162
|
+
"tsconfig": "{projectRoot}/tsconfig.json",
|
|
163
|
+
"silent": false,
|
|
164
|
+
"target": "esnext",
|
|
165
|
+
"format": [
|
|
166
|
+
"cjs",
|
|
167
|
+
"esm"
|
|
168
|
+
],
|
|
169
|
+
"platform": "neutral",
|
|
170
|
+
"external": [],
|
|
171
|
+
"define": {},
|
|
172
|
+
"env": {}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkCLMAB7TAjs = require('../../../chunk-CLMAB7TA.js');
|
|
4
|
+
require('../../../chunk-I734UVDT.js');
|
|
5
|
+
|
|
6
|
+
// src/executors/tsdown/untyped.ts
|
|
7
|
+
var _untyped = require('untyped');
|
|
8
|
+
var untyped_default = _untyped.defineUntypedSchema.call(void 0, {
|
|
9
|
+
..._chunkCLMAB7TAjs.typescript_build_executor_untyped_default,
|
|
10
|
+
$schema: {
|
|
11
|
+
id: "TSDownExecutorSchema",
|
|
12
|
+
title: "TSDown Executor",
|
|
13
|
+
description: "A type definition for an TSDown executor schema"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.default = untyped_default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
typescript_build_executor_untyped_default
|
|
3
|
+
} from "../../../chunk-MXVEXRT2.mjs";
|
|
4
|
+
import "../../../chunk-DGC5L3Z7.mjs";
|
|
5
|
+
import "../../../chunk-NMQP6WEB.mjs";
|
|
6
|
+
|
|
7
|
+
// src/executors/tsdown/untyped.ts
|
|
8
|
+
import { defineUntypedSchema } from "untyped";
|
|
9
|
+
var untyped_default = defineUntypedSchema({
|
|
10
|
+
...typescript_build_executor_untyped_default,
|
|
11
|
+
$schema: {
|
|
12
|
+
id: "TSDownExecutorSchema",
|
|
13
|
+
title: "TSDown Executor",
|
|
14
|
+
description: "A type definition for an TSDown executor schema"
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
untyped_default as default
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CreateNodesV2 } from '@nx/devkit';
|
|
2
|
+
|
|
3
|
+
declare const name = "storm-software/typescript/tsdown";
|
|
4
|
+
type TSDownPluginOptions = {
|
|
5
|
+
useRootDist?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const createNodesV2: CreateNodesV2<TSDownPluginOptions>;
|
|
8
|
+
|
|
9
|
+
export { type TSDownPluginOptions, createNodesV2, name };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CreateNodesV2 } from '@nx/devkit';
|
|
2
|
+
|
|
3
|
+
declare const name = "storm-software/typescript/tsdown";
|
|
4
|
+
type TSDownPluginOptions = {
|
|
5
|
+
useRootDist?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const createNodesV2: CreateNodesV2<TSDownPluginOptions>;
|
|
8
|
+
|
|
9
|
+
export { type TSDownPluginOptions, createNodesV2, name };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkJ6F3WHRBjs = require('../../../chunk-J6F3WHRB.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkAX3RSZT7js = require('../../../chunk-AX3RSZT7.js');
|
|
7
|
+
|
|
8
|
+
// src/plugins/typescript/tsdown.ts
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _devkit = require('@nx/devkit');
|
|
13
|
+
var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
|
|
14
|
+
var _fs = require('fs');
|
|
15
|
+
var _path = require('path');
|
|
16
|
+
var _nxjsonjs = require('nx/src/config/nx-json.js');
|
|
17
|
+
var _packagejson = require('nx/src/utils/package-json');
|
|
18
|
+
var name = "storm-software/typescript/tsdown";
|
|
19
|
+
var createNodesV2 = [
|
|
20
|
+
"**/tsdown.config.ts",
|
|
21
|
+
async (configFiles, options, context) => {
|
|
22
|
+
return await _devkit.createNodesFromFiles.call(void 0,
|
|
23
|
+
(configFile, options2, context2) => {
|
|
24
|
+
try {
|
|
25
|
+
const projectRoot = createProjectRoot(
|
|
26
|
+
configFile,
|
|
27
|
+
context2.workspaceRoot
|
|
28
|
+
);
|
|
29
|
+
if (!projectRoot) {
|
|
30
|
+
console.error(
|
|
31
|
+
`[storm-software/typescript/tsdown]: tsdown.config.ts file must be location in the project root directory: ${configFile}`
|
|
32
|
+
);
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
const packageJson = _devkit.readJsonFile.call(void 0, _path.join.call(void 0, projectRoot, "package.json"));
|
|
36
|
+
if (!packageJson) {
|
|
37
|
+
console.error(
|
|
38
|
+
`[storm-software/typescript/tsdown]: No package.json found in project root: ${projectRoot}`
|
|
39
|
+
);
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
if (!_optionalChain([packageJson, 'access', _ => _.devDependencies, 'optionalAccess', _2 => _2.tsdown]) && !_optionalChain([packageJson, 'access', _3 => _3.dependencies, 'optionalAccess', _4 => _4.tsdown])) {
|
|
43
|
+
console.warn(
|
|
44
|
+
`[storm-software/typescript/tsdown]: No "tsdown" dependency or devDependency found in package.json: ${configFile}
|
|
45
|
+
Please add it to your dependencies by running \`pnpm add tsdown -D --filter="${packageJson.name}"\``
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const project = createProjectFromPackageJsonNextToProjectJson(
|
|
49
|
+
_path.join.call(void 0, projectRoot, "project.json"),
|
|
50
|
+
packageJson
|
|
51
|
+
);
|
|
52
|
+
const nxJson = _nxjsonjs.readNxJson.call(void 0, context2.workspaceRoot);
|
|
53
|
+
const targets = _packagejson.readTargetsFromPackageJson.call(void 0,
|
|
54
|
+
packageJson,
|
|
55
|
+
nxJson,
|
|
56
|
+
projectRoot,
|
|
57
|
+
context2.workspaceRoot
|
|
58
|
+
);
|
|
59
|
+
const root = _chunkJ6F3WHRBjs.getRoot.call(void 0, projectRoot, context2);
|
|
60
|
+
let relativeConfig = configFile.replaceAll(root, "");
|
|
61
|
+
while (relativeConfig.startsWith(".")) {
|
|
62
|
+
relativeConfig = relativeConfig.slice(1);
|
|
63
|
+
}
|
|
64
|
+
while (relativeConfig.startsWith("/")) {
|
|
65
|
+
relativeConfig = relativeConfig.slice(1);
|
|
66
|
+
}
|
|
67
|
+
targets[_optionalChain([options2, 'optionalAccess', _5 => _5.useRootDist]) !== false ? "build-base" : "build"] = {
|
|
68
|
+
cache: true,
|
|
69
|
+
inputs: [
|
|
70
|
+
`{workspaceRoot}/${configFile}`,
|
|
71
|
+
"typescript",
|
|
72
|
+
"^production"
|
|
73
|
+
],
|
|
74
|
+
outputs: ["{projectRoot}/dist"],
|
|
75
|
+
executor: "nx:run-commands",
|
|
76
|
+
dependsOn: ["build-untyped", "type-check", "^build"],
|
|
77
|
+
options: {
|
|
78
|
+
command: `tsdown --config="${relativeConfig}"`,
|
|
79
|
+
cwd: root
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
if (_optionalChain([options2, 'optionalAccess', _6 => _6.useRootDist]) !== false) {
|
|
83
|
+
targets.build = {
|
|
84
|
+
cache: true,
|
|
85
|
+
inputs: [
|
|
86
|
+
"{workspaceRoot}/LICENSE",
|
|
87
|
+
"{projectRoot}/dist",
|
|
88
|
+
"{projectRoot}/*.md",
|
|
89
|
+
"{projectRoot}/package.json"
|
|
90
|
+
],
|
|
91
|
+
outputs: [`{workspaceRoot}/dist/${root}`],
|
|
92
|
+
executor: "nx:run-commands",
|
|
93
|
+
dependsOn: ["build-base", "build-untyped", "^build"],
|
|
94
|
+
options: {
|
|
95
|
+
commands: [
|
|
96
|
+
`pnpm copyfiles LICENSE dist/${root}`,
|
|
97
|
+
`pnpm copyfiles --up=2 ./${root}/*.md ./${root}/package.json dist/${root}`,
|
|
98
|
+
`pnpm copyfiles --up=3 "./${root}/dist/**/*" dist/${root}/dist`
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
targets.clean = {
|
|
104
|
+
executor: "nx:run-commands",
|
|
105
|
+
inputs: [
|
|
106
|
+
`{workspaceRoot}/${configFile}`,
|
|
107
|
+
"typescript",
|
|
108
|
+
"^production"
|
|
109
|
+
],
|
|
110
|
+
options: {
|
|
111
|
+
commands: [
|
|
112
|
+
`pnpm exec rimraf dist/${root}`,
|
|
113
|
+
`pnpm exec rimraf ${root}/dist`
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
_chunkAX3RSZT7js.setDefaultProjectTags.call(void 0, project, name);
|
|
118
|
+
return {
|
|
119
|
+
projects: {
|
|
120
|
+
[root]: _defu2.default.call(void 0,
|
|
121
|
+
{
|
|
122
|
+
root,
|
|
123
|
+
targets
|
|
124
|
+
},
|
|
125
|
+
project
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
} catch (e) {
|
|
130
|
+
console.error(e);
|
|
131
|
+
return {};
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
configFiles,
|
|
135
|
+
options,
|
|
136
|
+
context
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
];
|
|
140
|
+
function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, packageJson) {
|
|
141
|
+
const { nx, name: name2 } = packageJson;
|
|
142
|
+
const root = _path.dirname.call(void 0, projectJsonPath);
|
|
143
|
+
const projectJson = _devkit.readJsonFile.call(void 0, projectJsonPath);
|
|
144
|
+
return {
|
|
145
|
+
targets: {},
|
|
146
|
+
tags: [],
|
|
147
|
+
name: name2,
|
|
148
|
+
...nx,
|
|
149
|
+
...projectJson,
|
|
150
|
+
root
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function createProjectRoot(configPath, workspaceRoot) {
|
|
154
|
+
try {
|
|
155
|
+
const root = _path.dirname.call(void 0, configPath);
|
|
156
|
+
const projectRoot = _path.join.call(void 0, workspaceRoot, root);
|
|
157
|
+
if (!_fs.existsSync.call(void 0, _path.join.call(void 0, projectRoot, "package.json")) && !_fs.existsSync.call(void 0, _path.join.call(void 0, projectRoot, "project.json"))) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
return projectRoot;
|
|
161
|
+
} catch (e) {
|
|
162
|
+
console.error(e);
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
exports.createNodesV2 = createNodesV2; exports.name = name;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getRoot
|
|
3
|
+
} from "../../../chunk-4RYLWWPW.mjs";
|
|
4
|
+
import {
|
|
5
|
+
setDefaultProjectTags
|
|
6
|
+
} from "../../../chunk-F66XEAID.mjs";
|
|
7
|
+
import "../../../chunk-NMQP6WEB.mjs";
|
|
8
|
+
|
|
9
|
+
// src/plugins/typescript/tsdown.ts
|
|
10
|
+
import {
|
|
11
|
+
createNodesFromFiles,
|
|
12
|
+
readJsonFile
|
|
13
|
+
} from "@nx/devkit";
|
|
14
|
+
import defu from "defu";
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
import { dirname, join } from "node:path";
|
|
17
|
+
import { readNxJson } from "nx/src/config/nx-json.js";
|
|
18
|
+
import { readTargetsFromPackageJson } from "nx/src/utils/package-json";
|
|
19
|
+
var name = "storm-software/typescript/tsdown";
|
|
20
|
+
var createNodesV2 = [
|
|
21
|
+
"**/tsdown.config.ts",
|
|
22
|
+
async (configFiles, options, context) => {
|
|
23
|
+
return await createNodesFromFiles(
|
|
24
|
+
(configFile, options2, context2) => {
|
|
25
|
+
try {
|
|
26
|
+
const projectRoot = createProjectRoot(
|
|
27
|
+
configFile,
|
|
28
|
+
context2.workspaceRoot
|
|
29
|
+
);
|
|
30
|
+
if (!projectRoot) {
|
|
31
|
+
console.error(
|
|
32
|
+
`[storm-software/typescript/tsdown]: tsdown.config.ts file must be location in the project root directory: ${configFile}`
|
|
33
|
+
);
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
const packageJson = readJsonFile(join(projectRoot, "package.json"));
|
|
37
|
+
if (!packageJson) {
|
|
38
|
+
console.error(
|
|
39
|
+
`[storm-software/typescript/tsdown]: No package.json found in project root: ${projectRoot}`
|
|
40
|
+
);
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
if (!packageJson.devDependencies?.tsdown && !packageJson.dependencies?.tsdown) {
|
|
44
|
+
console.warn(
|
|
45
|
+
`[storm-software/typescript/tsdown]: No "tsdown" dependency or devDependency found in package.json: ${configFile}
|
|
46
|
+
Please add it to your dependencies by running \`pnpm add tsdown -D --filter="${packageJson.name}"\``
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
const project = createProjectFromPackageJsonNextToProjectJson(
|
|
50
|
+
join(projectRoot, "project.json"),
|
|
51
|
+
packageJson
|
|
52
|
+
);
|
|
53
|
+
const nxJson = readNxJson(context2.workspaceRoot);
|
|
54
|
+
const targets = readTargetsFromPackageJson(
|
|
55
|
+
packageJson,
|
|
56
|
+
nxJson,
|
|
57
|
+
projectRoot,
|
|
58
|
+
context2.workspaceRoot
|
|
59
|
+
);
|
|
60
|
+
const root = getRoot(projectRoot, context2);
|
|
61
|
+
let relativeConfig = configFile.replaceAll(root, "");
|
|
62
|
+
while (relativeConfig.startsWith(".")) {
|
|
63
|
+
relativeConfig = relativeConfig.slice(1);
|
|
64
|
+
}
|
|
65
|
+
while (relativeConfig.startsWith("/")) {
|
|
66
|
+
relativeConfig = relativeConfig.slice(1);
|
|
67
|
+
}
|
|
68
|
+
targets[options2?.useRootDist !== false ? "build-base" : "build"] = {
|
|
69
|
+
cache: true,
|
|
70
|
+
inputs: [
|
|
71
|
+
`{workspaceRoot}/${configFile}`,
|
|
72
|
+
"typescript",
|
|
73
|
+
"^production"
|
|
74
|
+
],
|
|
75
|
+
outputs: ["{projectRoot}/dist"],
|
|
76
|
+
executor: "nx:run-commands",
|
|
77
|
+
dependsOn: ["build-untyped", "type-check", "^build"],
|
|
78
|
+
options: {
|
|
79
|
+
command: `tsdown --config="${relativeConfig}"`,
|
|
80
|
+
cwd: root
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
if (options2?.useRootDist !== false) {
|
|
84
|
+
targets.build = {
|
|
85
|
+
cache: true,
|
|
86
|
+
inputs: [
|
|
87
|
+
"{workspaceRoot}/LICENSE",
|
|
88
|
+
"{projectRoot}/dist",
|
|
89
|
+
"{projectRoot}/*.md",
|
|
90
|
+
"{projectRoot}/package.json"
|
|
91
|
+
],
|
|
92
|
+
outputs: [`{workspaceRoot}/dist/${root}`],
|
|
93
|
+
executor: "nx:run-commands",
|
|
94
|
+
dependsOn: ["build-base", "build-untyped", "^build"],
|
|
95
|
+
options: {
|
|
96
|
+
commands: [
|
|
97
|
+
`pnpm copyfiles LICENSE dist/${root}`,
|
|
98
|
+
`pnpm copyfiles --up=2 ./${root}/*.md ./${root}/package.json dist/${root}`,
|
|
99
|
+
`pnpm copyfiles --up=3 "./${root}/dist/**/*" dist/${root}/dist`
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
targets.clean = {
|
|
105
|
+
executor: "nx:run-commands",
|
|
106
|
+
inputs: [
|
|
107
|
+
`{workspaceRoot}/${configFile}`,
|
|
108
|
+
"typescript",
|
|
109
|
+
"^production"
|
|
110
|
+
],
|
|
111
|
+
options: {
|
|
112
|
+
commands: [
|
|
113
|
+
`pnpm exec rimraf dist/${root}`,
|
|
114
|
+
`pnpm exec rimraf ${root}/dist`
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
setDefaultProjectTags(project, name);
|
|
119
|
+
return {
|
|
120
|
+
projects: {
|
|
121
|
+
[root]: defu(
|
|
122
|
+
{
|
|
123
|
+
root,
|
|
124
|
+
targets
|
|
125
|
+
},
|
|
126
|
+
project
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
} catch (e) {
|
|
131
|
+
console.error(e);
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
configFiles,
|
|
136
|
+
options,
|
|
137
|
+
context
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, packageJson) {
|
|
142
|
+
const { nx, name: name2 } = packageJson;
|
|
143
|
+
const root = dirname(projectJsonPath);
|
|
144
|
+
const projectJson = readJsonFile(projectJsonPath);
|
|
145
|
+
return {
|
|
146
|
+
targets: {},
|
|
147
|
+
tags: [],
|
|
148
|
+
name: name2,
|
|
149
|
+
...nx,
|
|
150
|
+
...projectJson,
|
|
151
|
+
root
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function createProjectRoot(configPath, workspaceRoot) {
|
|
155
|
+
try {
|
|
156
|
+
const root = dirname(configPath);
|
|
157
|
+
const projectRoot = join(workspaceRoot, root);
|
|
158
|
+
if (!existsSync(join(projectRoot, "package.json")) && !existsSync(join(projectRoot, "project.json"))) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
return projectRoot;
|
|
162
|
+
} catch (e) {
|
|
163
|
+
console.error(e);
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
createNodesV2,
|
|
169
|
+
name
|
|
170
|
+
};
|