@umijs/plugin-run 4.0.0-canary-20240513.3
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +108 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present ChenCheng (sorrycc@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/index.ts
|
|
30
|
+
var src_exports = {};
|
|
31
|
+
__export(src_exports, {
|
|
32
|
+
default: () => src_default,
|
|
33
|
+
getBinPath: () => getBinPath,
|
|
34
|
+
getFileNameByPath: () => getFileNameByPath
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
|
37
|
+
var import_assert = __toESM(require("assert"));
|
|
38
|
+
var import_child_process = require("child_process");
|
|
39
|
+
var import_fs = require("fs");
|
|
40
|
+
var import_path = require("path");
|
|
41
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
42
|
+
var src_default = (api) => {
|
|
43
|
+
api.describe({
|
|
44
|
+
key: "run",
|
|
45
|
+
config: {
|
|
46
|
+
schema({ zod }) {
|
|
47
|
+
return zod.object({
|
|
48
|
+
globals: zod.array(zod.string()).optional()
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
api.registerCommand({
|
|
54
|
+
name: "run",
|
|
55
|
+
description: "run the script commands, support for ts and zx",
|
|
56
|
+
configResolveMode: "loose",
|
|
57
|
+
fn: ({ args }) => {
|
|
58
|
+
var _a;
|
|
59
|
+
const globals = ((_a = api.config.run) == null ? void 0 : _a.globals) || [];
|
|
60
|
+
const [scriptFilePath, ...restArgs] = args._;
|
|
61
|
+
const absScriptFilePath = (0, import_path.join)(api.cwd, scriptFilePath);
|
|
62
|
+
const fileName = getFileNameByPath(absScriptFilePath);
|
|
63
|
+
(0, import_assert.default)(fileName, `${absScriptFilePath} is not a valid file`);
|
|
64
|
+
(0, import_assert.default)(
|
|
65
|
+
/\.([jt])s$/.test(fileName),
|
|
66
|
+
`${fileName} is not a valid js or ts file`
|
|
67
|
+
);
|
|
68
|
+
const absTmpFilePath = (0, import_path.join)(
|
|
69
|
+
api.paths.absNodeModulesPath,
|
|
70
|
+
".cache",
|
|
71
|
+
"umi-plugin-run",
|
|
72
|
+
fileName
|
|
73
|
+
);
|
|
74
|
+
import_plugin_utils.fsExtra.mkdirpSync((0, import_path.dirname)(absTmpFilePath));
|
|
75
|
+
(0, import_fs.writeFileSync)(
|
|
76
|
+
absTmpFilePath,
|
|
77
|
+
`${globals.map(
|
|
78
|
+
(item) => `import '${item}'
|
|
79
|
+
`
|
|
80
|
+
)}import '${absScriptFilePath}';`,
|
|
81
|
+
"utf-8"
|
|
82
|
+
);
|
|
83
|
+
const tsxPath = getBinPath();
|
|
84
|
+
(0, import_child_process.fork)(tsxPath, [absTmpFilePath, ...restArgs], {
|
|
85
|
+
stdio: "inherit",
|
|
86
|
+
env: {
|
|
87
|
+
...process.env,
|
|
88
|
+
// disable `(node:92349) ExperimentalWarning: `--experimental-loader` may be removed in the future;` warning
|
|
89
|
+
// more context: https://github.com/umijs/umi/pull/11981
|
|
90
|
+
NODE_NO_WARNINGS: "1"
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
function getBinPath() {
|
|
97
|
+
const pkgPath = import_plugin_utils.resolve.sync("tsx/package.json", { basedir: __dirname });
|
|
98
|
+
const pkgContent = require(pkgPath);
|
|
99
|
+
return (0, import_path.join)((0, import_path.dirname)(pkgPath), pkgContent.bin);
|
|
100
|
+
}
|
|
101
|
+
function getFileNameByPath(params) {
|
|
102
|
+
return params.split("/").at(-1);
|
|
103
|
+
}
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
getBinPath,
|
|
107
|
+
getFileNameByPath
|
|
108
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@umijs/plugin-run",
|
|
3
|
+
"version": "4.0.0-canary-20240513.3",
|
|
4
|
+
"description": "@umijs/plugin-run",
|
|
5
|
+
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugin-run#readme",
|
|
6
|
+
"bugs": "https://github.com/umijs/umi/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/umijs/umi"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"tsx": "3.12.2"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"authors": [
|
|
24
|
+
"chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "umi-scripts father build",
|
|
28
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
29
|
+
"dev": "umi-scripts father dev"
|
|
30
|
+
}
|
|
31
|
+
}
|