jiek 0.4.7-alpha.11 → 0.4.7-alpha.13
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cli.cjs +69 -60
- package/dist/cli.js +1 -1
- package/dist/cli.min.cjs +4 -4
- package/dist/cli.min.js +1 -1
- package/dist/rollup/index.cjs +43 -30
- package/dist/rollup/index.js +3 -2
- package/dist/rollup/index.min.cjs +4 -4
- package/dist/rollup/index.min.js +1 -1
- package/package.json +1 -1
- package/src/rollup/index.ts +3 -1
package/dist/cli.cjs
CHANGED
@@ -19,7 +19,10 @@ var bumper = require('@jiek/utils/bumper');
|
|
19
19
|
var entrypoints = require('@jiek/pkger/entrypoints');
|
20
20
|
|
21
21
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
22
|
-
function
|
22
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
23
|
+
|
24
|
+
function _interopNamespace(e) {
|
25
|
+
if (e && e.__esModule) return e;
|
23
26
|
var n = Object.create(null);
|
24
27
|
if (e) {
|
25
28
|
Object.keys(e).forEach(function (k) {
|
@@ -36,14 +39,20 @@ function _interopNamespaceDefault(e) {
|
|
36
39
|
return Object.freeze(n);
|
37
40
|
}
|
38
41
|
|
39
|
-
var
|
42
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
43
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
44
|
+
var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
|
45
|
+
var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
|
46
|
+
var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
|
47
|
+
var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
|
48
|
+
var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
|
40
49
|
|
41
50
|
let root;
|
42
51
|
function getRoot() {
|
43
52
|
if (root)
|
44
53
|
return root;
|
45
54
|
const rootOption = commander.program.getOptionValue("root");
|
46
|
-
root = rootOption ?
|
55
|
+
root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : void 0;
|
47
56
|
return root;
|
48
57
|
}
|
49
58
|
|
@@ -87,18 +96,18 @@ async function getSelectedProjectsGraph() {
|
|
87
96
|
const root = getRoot();
|
88
97
|
const { wd, notWorkspace } = getWD();
|
89
98
|
if (!notWorkspace && type$1 === "pnpm") {
|
90
|
-
const pnpmWorkspaceFilePath =
|
91
|
-
const pnpmWorkspaceFileContent =
|
99
|
+
const pnpmWorkspaceFilePath = path__default.default.resolve(wd, "pnpm-workspace.yaml");
|
100
|
+
const pnpmWorkspaceFileContent = fs__default.default.readFileSync(pnpmWorkspaceFilePath, "utf-8");
|
92
101
|
const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
|
93
102
|
if (root === wd && !filter) {
|
94
103
|
throw new Error("root path is workspace root, please provide a filter");
|
95
104
|
}
|
96
105
|
if (root !== wd && !filter) {
|
97
|
-
const packageJSONIsExist =
|
106
|
+
const packageJSONIsExist = fs__default.default.existsSync(path__default.default.resolve(root, "package.json"));
|
98
107
|
if (!packageJSONIsExist) {
|
99
108
|
throw new Error("root path is not workspace root, please provide a filter");
|
100
109
|
}
|
101
|
-
const packageJSON = JSON.parse(
|
110
|
+
const packageJSON = JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(root, "package.json"), "utf-8"));
|
102
111
|
if (!packageJSON.name) {
|
103
112
|
throw new Error("root path is not workspace root, please provide a filter");
|
104
113
|
}
|
@@ -125,14 +134,14 @@ async function getSelectedProjectsGraph() {
|
|
125
134
|
wd,
|
126
135
|
root,
|
127
136
|
value: {
|
128
|
-
[wd]: JSON.parse(
|
137
|
+
[wd]: JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(wd, "package.json"), "utf-8"))
|
129
138
|
}
|
130
139
|
};
|
131
140
|
}
|
132
141
|
|
133
142
|
var name = "jiek";
|
134
143
|
var type = "module";
|
135
|
-
var version = "0.4.7-alpha.
|
144
|
+
var version = "0.4.7-alpha.12";
|
136
145
|
var description = "YiJie's personal kits.";
|
137
146
|
var bin = {
|
138
147
|
jiek: "bin/jiek.js",
|
@@ -257,19 +266,19 @@ function getConfigPath(root, dir) {
|
|
257
266
|
const isSupportTsLoader = !!tsRegisterName;
|
258
267
|
function configWithExtIsExist(ext) {
|
259
268
|
const filenames = [
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
269
|
+
path__default.default.resolve(process.cwd(), `${configName}.${ext}`),
|
270
|
+
path__default.default.resolve(process.cwd(), `.${configName}.${ext}`),
|
271
|
+
path__default.default.resolve(root, `${configName}.${ext}`),
|
272
|
+
path__default.default.resolve(root, `.${configName}.${ext}`)
|
264
273
|
];
|
265
274
|
if (dir) {
|
266
275
|
filenames.unshift(...[
|
267
|
-
|
268
|
-
|
276
|
+
path__default.default.resolve(dir, `${configName}.${ext}`),
|
277
|
+
path__default.default.resolve(dir, `.${configName}.${ext}`)
|
269
278
|
]);
|
270
279
|
}
|
271
280
|
for (const filename of filenames) {
|
272
|
-
if (
|
281
|
+
if (fs__default.default.existsSync(filename) && fs__default.default.lstatSync(filename).isFile()) {
|
273
282
|
return filename;
|
274
283
|
}
|
275
284
|
}
|
@@ -281,7 +290,7 @@ function getConfigPath(root, dir) {
|
|
281
290
|
if (isSupportTsLoader) {
|
282
291
|
configName = configWithExtIsExist("ts") ?? configName;
|
283
292
|
}
|
284
|
-
return
|
293
|
+
return path__default.default.resolve(root, configName);
|
285
294
|
}
|
286
295
|
function loadConfig(dir) {
|
287
296
|
const { wd: root } = getWD();
|
@@ -289,14 +298,14 @@ function loadConfig(dir) {
|
|
289
298
|
if (!configPath) {
|
290
299
|
configPath = getConfigPath(root, dir);
|
291
300
|
} else {
|
292
|
-
if (!
|
301
|
+
if (!fs__default.default.existsSync(configPath)) {
|
293
302
|
throw new Error(`config file not found: ${configPath}`);
|
294
303
|
}
|
295
|
-
if (!
|
296
|
-
configPath =
|
304
|
+
if (!path__default.default.isAbsolute(configPath)) {
|
305
|
+
configPath = path__default.default.resolve(root, configPath);
|
297
306
|
}
|
298
307
|
}
|
299
|
-
const ext =
|
308
|
+
const ext = path__default.default.extname(configPath);
|
300
309
|
let module;
|
301
310
|
switch (ext) {
|
302
311
|
case ".js":
|
@@ -305,7 +314,7 @@ function loadConfig(dir) {
|
|
305
314
|
case ".json":
|
306
315
|
return require(configPath);
|
307
316
|
case ".yaml":
|
308
|
-
return jsYaml.load(
|
317
|
+
return jsYaml.load(fs__default.default.readFileSync(configPath, "utf-8"));
|
309
318
|
case ".ts":
|
310
319
|
if (tsRegisterName) {
|
311
320
|
require(tsRegisterName);
|
@@ -344,13 +353,13 @@ commander.program.command("build").option("-s, --silent", "Don't display logs.")
|
|
344
353
|
if (Object.keys(value).length === 0) {
|
345
354
|
throw new Error("no package found");
|
346
355
|
}
|
347
|
-
const wdNodeModules =
|
348
|
-
if (!
|
349
|
-
|
356
|
+
const wdNodeModules = path__default.default.resolve(wd, "node_modules");
|
357
|
+
if (!fs__default.default.existsSync(wdNodeModules)) {
|
358
|
+
fs__default.default.mkdirSync(wdNodeModules);
|
350
359
|
}
|
351
|
-
const jiekTempDir = (...paths) =>
|
352
|
-
if (!
|
353
|
-
|
360
|
+
const jiekTempDir = (...paths) => path__default.default.resolve(wdNodeModules, ".jiek", ...paths);
|
361
|
+
if (!fs__default.default.existsSync(jiekTempDir())) {
|
362
|
+
fs__default.default.mkdirSync(jiekTempDir());
|
354
363
|
}
|
355
364
|
const rollupBinaryPath = require$1.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
356
365
|
const multiBars = new cliProgress.MultiBar({
|
@@ -365,7 +374,7 @@ commander.program.command("build").option("-s, --silent", "Don't display logs.")
|
|
365
374
|
const configFile = jiekTempDir(
|
366
375
|
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
367
376
|
);
|
368
|
-
|
377
|
+
fs__default.default.writeFileSync(configFile, FILE_TEMPLATE(manifest));
|
369
378
|
let prefix = "";
|
370
379
|
if (tsRegisterName) {
|
371
380
|
prefix = `node -r ${tsRegisterName} `;
|
@@ -951,7 +960,7 @@ function requireFillRange () {
|
|
951
960
|
if (hasRequiredFillRange) return fillRange;
|
952
961
|
hasRequiredFillRange = 1;
|
953
962
|
|
954
|
-
const util = require$$
|
963
|
+
const util = require$$0__default.default;
|
955
964
|
const toRegexRange = requireToRegexRange();
|
956
965
|
|
957
966
|
const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
@@ -1970,7 +1979,7 @@ function requireConstants () {
|
|
1970
1979
|
if (hasRequiredConstants) return constants;
|
1971
1980
|
hasRequiredConstants = 1;
|
1972
1981
|
|
1973
|
-
const path = require$$
|
1982
|
+
const path = require$$0__default$1.default;
|
1974
1983
|
const WIN_SLASH = '\\\\/';
|
1975
1984
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
1976
1985
|
|
@@ -2157,7 +2166,7 @@ function requireUtils () {
|
|
2157
2166
|
hasRequiredUtils = 1;
|
2158
2167
|
(function (exports) {
|
2159
2168
|
|
2160
|
-
const path = require$$
|
2169
|
+
const path = require$$0__default$1.default;
|
2161
2170
|
const win32 = process.platform === 'win32';
|
2162
2171
|
const {
|
2163
2172
|
REGEX_BACKSLASH,
|
@@ -3728,7 +3737,7 @@ function requirePicomatch$1 () {
|
|
3728
3737
|
if (hasRequiredPicomatch$1) return picomatch_1;
|
3729
3738
|
hasRequiredPicomatch$1 = 1;
|
3730
3739
|
|
3731
|
-
const path = require$$
|
3740
|
+
const path = require$$0__default$1.default;
|
3732
3741
|
const scan = requireScan();
|
3733
3742
|
const parse = requireParse();
|
3734
3743
|
const utils = requireUtils();
|
@@ -4089,7 +4098,7 @@ function requireMicromatch () {
|
|
4089
4098
|
if (hasRequiredMicromatch) return micromatch_1;
|
4090
4099
|
hasRequiredMicromatch = 1;
|
4091
4100
|
|
4092
|
-
const util = require$$
|
4101
|
+
const util = require$$0__default.default;
|
4093
4102
|
const braces = requireBraces();
|
4094
4103
|
const picomatch = requirePicomatch();
|
4095
4104
|
const utils = requireUtils();
|
@@ -4604,8 +4613,8 @@ function getTemplateStr(wd, template) {
|
|
4604
4613
|
isTemplateFile = true;
|
4605
4614
|
}
|
4606
4615
|
if (isTemplateFile) {
|
4607
|
-
const templatePath =
|
4608
|
-
templateString =
|
4616
|
+
const templatePath = path__default.default.resolve(wd, template);
|
4617
|
+
templateString = fs__default.default.readFileSync(templatePath, "utf-8");
|
4609
4618
|
}
|
4610
4619
|
return templateString;
|
4611
4620
|
}
|
@@ -4614,8 +4623,8 @@ function getWDPackageJSONFiled(wd, field) {
|
|
4614
4623
|
if (wdCache.has(wd)) {
|
4615
4624
|
return wdCache.get(wd)[field];
|
4616
4625
|
}
|
4617
|
-
const packageJSONPath =
|
4618
|
-
const packageJSON = JSON.parse(
|
4626
|
+
const packageJSONPath = path__default.default.resolve(wd, "package.json");
|
4627
|
+
const packageJSON = JSON.parse(fs__default.default.readFileSync(packageJSONPath, "utf-8"));
|
4619
4628
|
wdCache.set(wd, packageJSON);
|
4620
4629
|
return packageJSON[field];
|
4621
4630
|
}
|
@@ -4625,7 +4634,7 @@ async function getName(named, name, {
|
|
4625
4634
|
workspaceName
|
4626
4635
|
}) {
|
4627
4636
|
const relativePath = cwd.replace(`${wd}/`, "");
|
4628
|
-
let basename =
|
4637
|
+
let basename = path__default.default.basename(cwd);
|
4629
4638
|
if (typeof named === "function") {
|
4630
4639
|
return named(name, {
|
4631
4640
|
full: wd,
|
@@ -4638,7 +4647,7 @@ async function getName(named, name, {
|
|
4638
4647
|
if (typeof named === "object") {
|
4639
4648
|
const isWD = cwd === wd;
|
4640
4649
|
if (isWD) {
|
4641
|
-
const { rule } = await
|
4650
|
+
const { rule } = await inquirer__default.default.prompt({
|
4642
4651
|
type: "list",
|
4643
4652
|
name: "rule",
|
4644
4653
|
message: "choose a rule",
|
@@ -4673,7 +4682,7 @@ async function getName(named, name, {
|
|
4673
4682
|
throw new Error("no matched rule");
|
4674
4683
|
}
|
4675
4684
|
if (!name && isParentMatched) {
|
4676
|
-
basename = await
|
4685
|
+
basename = await inquirer__default.default.prompt({
|
4677
4686
|
type: "input",
|
4678
4687
|
name: "name",
|
4679
4688
|
message: `the matched rule is \`${String(matchedRule)}\`, please input the basename
|
@@ -4701,7 +4710,7 @@ commander.program.command("init [name]").option("-t, --template <template>", "th
|
|
4701
4710
|
const cwd = process.cwd();
|
4702
4711
|
const { init = {} } = loadConfig() ?? {};
|
4703
4712
|
const { wd } = getWD();
|
4704
|
-
const workspaceName =
|
4713
|
+
const workspaceName = path__default.default.basename(wd);
|
4705
4714
|
const {
|
4706
4715
|
named,
|
4707
4716
|
template,
|
@@ -4716,11 +4725,11 @@ commander.program.command("init [name]").option("-t, --template <template>", "th
|
|
4716
4725
|
};
|
4717
4726
|
let readme = _readme;
|
4718
4727
|
if (readmeTemplate) {
|
4719
|
-
const readmeTemplatePath =
|
4720
|
-
readme =
|
4728
|
+
const readmeTemplatePath = path__default.default.resolve(wd, readmeTemplate);
|
4729
|
+
readme = fs__default.default.readFileSync(readmeTemplatePath, "utf-8");
|
4721
4730
|
}
|
4722
4731
|
const templateString = getTemplateStr(wd, template);
|
4723
|
-
const { indent = " " } =
|
4732
|
+
const { indent = " " } = detectIndent__default.default(templateString);
|
4724
4733
|
const formattingOptions = {
|
4725
4734
|
tabSize: indent.length,
|
4726
4735
|
insertSpaces: true
|
@@ -4747,7 +4756,7 @@ commander.program.command("init [name]").option("-t, --template <template>", "th
|
|
4747
4756
|
workspaceName
|
4748
4757
|
});
|
4749
4758
|
if (!pkgDir) {
|
4750
|
-
const { dir } = await
|
4759
|
+
const { dir } = await inquirer__default.default.prompt({
|
4751
4760
|
type: "input",
|
4752
4761
|
name: "dir",
|
4753
4762
|
message: "package directory",
|
@@ -4756,7 +4765,7 @@ commander.program.command("init [name]").option("-t, --template <template>", "th
|
|
4756
4765
|
pkgDir = dir;
|
4757
4766
|
}
|
4758
4767
|
if (!pkgName) {
|
4759
|
-
const { name: inputName } = await
|
4768
|
+
const { name: inputName } = await inquirer__default.default.prompt({
|
4760
4769
|
type: "input",
|
4761
4770
|
name: "name",
|
4762
4771
|
message: "package name",
|
@@ -4813,15 +4822,15 @@ commander.program.command("init [name]").option("-t, --template <template>", "th
|
|
4813
4822
|
function pkgDirTo(to) {
|
4814
4823
|
if (!pkgDir)
|
4815
4824
|
throw new Error("pkgDir is not defined");
|
4816
|
-
return
|
4825
|
+
return path__default.default.resolve(pkgDir, to);
|
4817
4826
|
}
|
4818
|
-
if (!
|
4819
|
-
|
4827
|
+
if (!fs__default.default.existsSync(pkgDir))
|
4828
|
+
fs__default.default.mkdirSync(pkgDir);
|
4820
4829
|
const pkgJSONFilePath = pkgDirTo("package.json");
|
4821
|
-
if (
|
4830
|
+
if (fs__default.default.existsSync(pkgJSONFilePath)) {
|
4822
4831
|
throw new Error("package.json already exists");
|
4823
4832
|
}
|
4824
|
-
|
4833
|
+
fs__default.default.writeFileSync(pkgJSONFilePath, newJSONString);
|
4825
4834
|
console.log(newJSONString, "written to", pkgJSONFilePath);
|
4826
4835
|
const license = getWDPackageJSONFiled(wd, "license");
|
4827
4836
|
const readmeFilePath = pkgDirTo("README.md");
|
@@ -4832,7 +4841,7 @@ commander.program.command("init [name]").option("-t, --template <template>", "th
|
|
4832
4841
|
});
|
4833
4842
|
}
|
4834
4843
|
const readmeContent = readme.replace(/\$name/g, pkgName).replace(/\$license/g, license);
|
4835
|
-
|
4844
|
+
fs__default.default.writeFileSync(readmeFilePath, readmeContent);
|
4836
4845
|
});
|
4837
4846
|
|
4838
4847
|
const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
|
@@ -4929,10 +4938,10 @@ commander.program.command("publish").aliases(["pub", "p"]).option("-b, --bumper
|
|
4929
4938
|
return acc;
|
4930
4939
|
}, []);
|
4931
4940
|
for (const [dir, manifest] of manifests) {
|
4932
|
-
const oldJSONString =
|
4941
|
+
const oldJSONString = fs__default.default.readFileSync(path__default.default.join(dir, "package.json"), "utf-8");
|
4933
4942
|
const oldJSON = JSON.parse(oldJSONString) ?? "0.0.0";
|
4934
4943
|
const newVersion = bumper.bump(oldJSON.version, bumper$1);
|
4935
|
-
const { indent = " " } =
|
4944
|
+
const { indent = " " } = detectIndent__default.default(oldJSONString);
|
4936
4945
|
const formattingOptions = {
|
4937
4946
|
tabSize: indent.length,
|
4938
4947
|
insertSpaces: true
|
@@ -5004,8 +5013,8 @@ commander.program.command("publish").aliases(["pub", "p"]).option("-b, --bumper
|
|
5004
5013
|
}
|
5005
5014
|
}
|
5006
5015
|
try {
|
5007
|
-
|
5008
|
-
|
5016
|
+
fs__default.default.renameSync(path__default.default.join(dir, "package.json"), path__default.default.join(dir, "package.json.bak"));
|
5017
|
+
fs__default.default.writeFileSync(path__default.default.join(dir, "package.json"), newJSONString);
|
5009
5018
|
console.log(newJSONString);
|
5010
5019
|
if (preview) {
|
5011
5020
|
console.warn("preview mode");
|
@@ -5016,10 +5025,10 @@ commander.program.command("publish").aliases(["pub", "p"]).option("-b, --bumper
|
|
5016
5025
|
stdio: "inherit"
|
5017
5026
|
});
|
5018
5027
|
const modifyVersionPackageJSON = jsoncParser.applyEdits(oldJSONString, jsoncParser.modify(oldJSONString, ["version"], newVersion, {}));
|
5019
|
-
|
5028
|
+
fs__default.default.writeFileSync(path__default.default.join(dir, "package.json.bak"), modifyVersionPackageJSON);
|
5020
5029
|
} finally {
|
5021
|
-
|
5022
|
-
|
5030
|
+
fs__default.default.unlinkSync(path__default.default.join(dir, "package.json"));
|
5031
|
+
fs__default.default.renameSync(path__default.default.join(dir, "package.json.bak"), path__default.default.join(dir, "package.json"));
|
5023
5032
|
}
|
5024
5033
|
}
|
5025
5034
|
actionDone();
|
package/dist/cli.js
CHANGED
@@ -110,7 +110,7 @@ async function getSelectedProjectsGraph() {
|
|
110
110
|
|
111
111
|
var name = "jiek";
|
112
112
|
var type = "module";
|
113
|
-
var version = "0.4.7-alpha.
|
113
|
+
var version = "0.4.7-alpha.12";
|
114
114
|
var description = "YiJie's personal kits.";
|
115
115
|
var bin = {
|
116
116
|
jiek: "bin/jiek.js",
|