dnmp 0.0.0-alpha.0.1 → 0.0.0-alpha.0.2
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/bin/cli.js +2 -0
- package/dist/cli.mjs +292 -0
- package/dist/cli.mjs.map +1 -0
- package/package.json +10 -4
- package/dist/index.mjs +0 -17
- package/dist/index.mjs.map +0 -1
- /package/dist/{index.d.mts → cli.d.mts} +0 -0
package/bin/cli.js
ADDED
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { cancel, intro, isCancel, outro, select, text } from "@clack/prompts";
|
|
2
|
+
import cac from "cac";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { x } from "tinyexec";
|
|
5
|
+
import { writeFile } from "node:fs/promises";
|
|
6
|
+
import { createJiti } from "jiti";
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import boxen from "boxen";
|
|
9
|
+
import * as process$1 from "node:process";
|
|
10
|
+
|
|
11
|
+
//#region rolldown:runtime
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
+
key = keys[i];
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: ((k) => from[k]).bind(null, key),
|
|
26
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
34
|
+
value: mod,
|
|
35
|
+
enumerable: true
|
|
36
|
+
}) : target, mod));
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
40
|
+
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
41
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
42
|
+
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
43
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
44
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
45
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
46
|
+
};
|
|
47
|
+
let replaceClose = (string, close, replace, index) => {
|
|
48
|
+
let result = "", cursor = 0;
|
|
49
|
+
do {
|
|
50
|
+
result += string.substring(cursor, index) + replace;
|
|
51
|
+
cursor = index + close.length;
|
|
52
|
+
index = string.indexOf(close, cursor);
|
|
53
|
+
} while (~index);
|
|
54
|
+
return result + string.substring(cursor);
|
|
55
|
+
};
|
|
56
|
+
let createColors = (enabled = isColorSupported) => {
|
|
57
|
+
let f = enabled ? formatter : () => String;
|
|
58
|
+
return {
|
|
59
|
+
isColorSupported: enabled,
|
|
60
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
61
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
62
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
63
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
64
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
65
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
66
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
67
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
68
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
69
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
70
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
71
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
72
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
73
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
74
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
75
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
76
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
77
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
78
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
79
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
80
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
81
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
82
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
83
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
84
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
85
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
86
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
87
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
88
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
89
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
90
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
91
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
92
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
93
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
94
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
95
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
96
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
97
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
98
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
99
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
100
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
module.exports = createColors();
|
|
104
|
+
module.exports.createColors = createColors;
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/constant.ts
|
|
109
|
+
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors());
|
|
110
|
+
const CACHE_FOLDER_NAME = ".cache";
|
|
111
|
+
const CACHE_FILE_NAME = "token.ts";
|
|
112
|
+
const CACHE_TOKEN_FILE_PATH = `${CACHE_FOLDER_NAME}/${CACHE_FILE_NAME}`;
|
|
113
|
+
const CUSTOM_RELEASE_PREFIX = "custom";
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/config.ts
|
|
117
|
+
const CURRENT_PATH = resolve(import.meta.dirname, "../");
|
|
118
|
+
const resolveConfig = async () => {
|
|
119
|
+
return {
|
|
120
|
+
cwd: CURRENT_PATH,
|
|
121
|
+
root: process.cwd(),
|
|
122
|
+
tokenFile: resolve(CURRENT_PATH, `${CACHE_TOKEN_FILE_PATH}`),
|
|
123
|
+
token: ""
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/runCommand.ts
|
|
129
|
+
const runCommand = async (config, command, args) => {
|
|
130
|
+
await x(command, args, { nodeOptions: {
|
|
131
|
+
stdio: "inherit",
|
|
132
|
+
cwd: config.root
|
|
133
|
+
} });
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/utils.ts
|
|
138
|
+
const checkDirExist = (dirPath) => {
|
|
139
|
+
return fs.existsSync(dirPath);
|
|
140
|
+
};
|
|
141
|
+
const createDir = (dirPath) => {
|
|
142
|
+
if (!checkDirExist(dirPath)) fs.mkdirSync(dirPath);
|
|
143
|
+
};
|
|
144
|
+
const printWarning = (message) => console.log(boxen(message, {
|
|
145
|
+
title: "Warning",
|
|
146
|
+
padding: 1,
|
|
147
|
+
borderStyle: "round",
|
|
148
|
+
borderColor: "yellow"
|
|
149
|
+
}));
|
|
150
|
+
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/token.ts
|
|
153
|
+
const setToken = async (config, token) => {
|
|
154
|
+
createDir(resolve(config.cwd, CACHE_FOLDER_NAME));
|
|
155
|
+
await writeFile(config.tokenFile, `export default "${token}"`);
|
|
156
|
+
};
|
|
157
|
+
const loaderToken = async (config) => {
|
|
158
|
+
return await createJiti(config.cwd).import(config.tokenFile, { default: true });
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/version.ts
|
|
163
|
+
const PADDING = 13;
|
|
164
|
+
const promptForNewVersion = async (config) => {
|
|
165
|
+
let custom = "";
|
|
166
|
+
const release = await select({
|
|
167
|
+
message: "Current version 0.0.0",
|
|
168
|
+
options: [
|
|
169
|
+
{
|
|
170
|
+
value: "major",
|
|
171
|
+
label: `${"major".padStart(PADDING, " ")} 0.0.0`
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
value: "minor",
|
|
175
|
+
label: `${"minor".padStart(PADDING, " ")} 0.0.0`
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
value: "patch",
|
|
179
|
+
label: `${"patch".padStart(PADDING, " ")} 0.0.0`
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
value: "next",
|
|
183
|
+
label: `${"next".padStart(PADDING, " ")} 0.0.0`
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
value: "rc",
|
|
187
|
+
label: `${"rc".padStart(PADDING, " ")} 0.0.0-${import_picocolors.default.green("rc")}.1`
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
value: "pre-beta-major",
|
|
191
|
+
label: `${"pre-major".padStart(PADDING, " ")} 0.0.0-${import_picocolors.default.magenta("beta")}.1`
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
value: "pre-beta-minor",
|
|
195
|
+
label: `${"pre-minor".padStart(PADDING, " ")} 0.0.0-${import_picocolors.default.magenta("beta")}.1`
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
value: "pre-beta-patch",
|
|
199
|
+
label: `${"pre-patch".padStart(PADDING, " ")} 0.0.0-${import_picocolors.default.magenta("beta")}.1`
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
value: "pre-beta",
|
|
203
|
+
label: `${"pre-beta".padStart(PADDING, " ")} 0.0.0-${import_picocolors.default.magenta("beta")}`
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
value: "pre-alpha-major",
|
|
207
|
+
label: `${"alpha".padStart(PADDING, " ")} 0.0.0-${import_picocolors.default.yellow("alpha")}.beta`
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
value: "pre-alpha-minor",
|
|
211
|
+
label: `${"alpha".padStart(PADDING, " ")} 0.0.0-${import_picocolors.default.yellow("alpha")}.1`
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
value: "pre-alpha-patch",
|
|
215
|
+
label: `${"alpha".padStart(PADDING, " ")} 0.0.0-${import_picocolors.default.yellow("alpha")}`
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
value: CUSTOM_RELEASE_PREFIX,
|
|
219
|
+
label: `${"custom".padStart(PADDING, " ")} ...`
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
initialValue: "next"
|
|
223
|
+
});
|
|
224
|
+
if (isCancel(release)) {
|
|
225
|
+
cancel("No version selected");
|
|
226
|
+
return process$1.exit(0);
|
|
227
|
+
}
|
|
228
|
+
if (release === CUSTOM_RELEASE_PREFIX) {
|
|
229
|
+
custom = await text({
|
|
230
|
+
message: "Enter the new version number",
|
|
231
|
+
placeholder: "e.g. major, minor, patch, pre-alpha, pre-beta, rc, ..."
|
|
232
|
+
});
|
|
233
|
+
if (isCancel(custom)) {
|
|
234
|
+
cancel("No version enter");
|
|
235
|
+
return process$1.exit(0);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
console.log({
|
|
239
|
+
release,
|
|
240
|
+
custom
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region package.json
|
|
246
|
+
var name = "dnmp";
|
|
247
|
+
var version = "0.0.0-alpha.0.2";
|
|
248
|
+
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/cli.ts
|
|
251
|
+
const cli = cac(name);
|
|
252
|
+
cli.command("").action(async (options) => {
|
|
253
|
+
const config = await resolveConfig();
|
|
254
|
+
config.token = await loaderToken(config);
|
|
255
|
+
console.log(config);
|
|
256
|
+
console.log(import.meta);
|
|
257
|
+
intro(import_picocolors.default.bgCyan(` dnmp ${version} `));
|
|
258
|
+
await promptForNewVersion(config);
|
|
259
|
+
console.log("npm", [
|
|
260
|
+
"publish",
|
|
261
|
+
`--//registry.npmjs.org/:_authToken=${config.token}`,
|
|
262
|
+
"--access",
|
|
263
|
+
"public"
|
|
264
|
+
].join(" "));
|
|
265
|
+
await runCommand(config, "npm", [
|
|
266
|
+
"publish",
|
|
267
|
+
`--//registry.npmjs.org/:_authToken=${config.token}`,
|
|
268
|
+
"--access",
|
|
269
|
+
"public"
|
|
270
|
+
]);
|
|
271
|
+
outro("Done.");
|
|
272
|
+
});
|
|
273
|
+
cli.command("set <token>", "Set the local release Token").action(async (token = "") => {
|
|
274
|
+
try {
|
|
275
|
+
await setToken(await resolveConfig(), token);
|
|
276
|
+
} catch (error) {
|
|
277
|
+
printWarning(error.message);
|
|
278
|
+
process.exit(1);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
cli.help();
|
|
282
|
+
cli.version(version);
|
|
283
|
+
try {
|
|
284
|
+
cli.parse();
|
|
285
|
+
} catch (error) {
|
|
286
|
+
printWarning(error.message);
|
|
287
|
+
process.exit(1);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
//#endregion
|
|
291
|
+
export { };
|
|
292
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["custom: string","pc","process","pc","error: any"],"sources":["../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js","../src/constant.ts","../src/config.ts","../src/runCommand.ts","../src/utils.ts","../src/token.ts","../src/version.ts","../package.json","../src/cli.ts"],"sourcesContent":["let p = process || {}, argv = p.argv || [], env = p.env || {}\nlet isColorSupported =\n\t!(!!env.NO_COLOR || argv.includes(\"--no-color\")) &&\n\t(!!env.FORCE_COLOR || argv.includes(\"--color\") || p.platform === \"win32\" || ((p.stdout || {}).isTTY && env.TERM !== \"dumb\") || !!env.CI)\n\nlet formatter = (open, close, replace = open) =>\n\tinput => {\n\t\tlet string = \"\" + input, index = string.indexOf(close, open.length)\n\t\treturn ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close\n\t}\n\nlet replaceClose = (string, close, replace, index) => {\n\tlet result = \"\", cursor = 0\n\tdo {\n\t\tresult += string.substring(cursor, index) + replace\n\t\tcursor = index + close.length\n\t\tindex = string.indexOf(close, cursor)\n\t} while (~index)\n\treturn result + string.substring(cursor)\n}\n\nlet createColors = (enabled = isColorSupported) => {\n\tlet f = enabled ? formatter : () => String\n\treturn {\n\t\tisColorSupported: enabled,\n\t\treset: f(\"\\x1b[0m\", \"\\x1b[0m\"),\n\t\tbold: f(\"\\x1b[1m\", \"\\x1b[22m\", \"\\x1b[22m\\x1b[1m\"),\n\t\tdim: f(\"\\x1b[2m\", \"\\x1b[22m\", \"\\x1b[22m\\x1b[2m\"),\n\t\titalic: f(\"\\x1b[3m\", \"\\x1b[23m\"),\n\t\tunderline: f(\"\\x1b[4m\", \"\\x1b[24m\"),\n\t\tinverse: f(\"\\x1b[7m\", \"\\x1b[27m\"),\n\t\thidden: f(\"\\x1b[8m\", \"\\x1b[28m\"),\n\t\tstrikethrough: f(\"\\x1b[9m\", \"\\x1b[29m\"),\n\n\t\tblack: f(\"\\x1b[30m\", \"\\x1b[39m\"),\n\t\tred: f(\"\\x1b[31m\", \"\\x1b[39m\"),\n\t\tgreen: f(\"\\x1b[32m\", \"\\x1b[39m\"),\n\t\tyellow: f(\"\\x1b[33m\", \"\\x1b[39m\"),\n\t\tblue: f(\"\\x1b[34m\", \"\\x1b[39m\"),\n\t\tmagenta: f(\"\\x1b[35m\", \"\\x1b[39m\"),\n\t\tcyan: f(\"\\x1b[36m\", \"\\x1b[39m\"),\n\t\twhite: f(\"\\x1b[37m\", \"\\x1b[39m\"),\n\t\tgray: f(\"\\x1b[90m\", \"\\x1b[39m\"),\n\n\t\tbgBlack: f(\"\\x1b[40m\", \"\\x1b[49m\"),\n\t\tbgRed: f(\"\\x1b[41m\", \"\\x1b[49m\"),\n\t\tbgGreen: f(\"\\x1b[42m\", \"\\x1b[49m\"),\n\t\tbgYellow: f(\"\\x1b[43m\", \"\\x1b[49m\"),\n\t\tbgBlue: f(\"\\x1b[44m\", \"\\x1b[49m\"),\n\t\tbgMagenta: f(\"\\x1b[45m\", \"\\x1b[49m\"),\n\t\tbgCyan: f(\"\\x1b[46m\", \"\\x1b[49m\"),\n\t\tbgWhite: f(\"\\x1b[47m\", \"\\x1b[49m\"),\n\n\t\tblackBright: f(\"\\x1b[90m\", \"\\x1b[39m\"),\n\t\tredBright: f(\"\\x1b[91m\", \"\\x1b[39m\"),\n\t\tgreenBright: f(\"\\x1b[92m\", \"\\x1b[39m\"),\n\t\tyellowBright: f(\"\\x1b[93m\", \"\\x1b[39m\"),\n\t\tblueBright: f(\"\\x1b[94m\", \"\\x1b[39m\"),\n\t\tmagentaBright: f(\"\\x1b[95m\", \"\\x1b[39m\"),\n\t\tcyanBright: f(\"\\x1b[96m\", \"\\x1b[39m\"),\n\t\twhiteBright: f(\"\\x1b[97m\", \"\\x1b[39m\"),\n\n\t\tbgBlackBright: f(\"\\x1b[100m\", \"\\x1b[49m\"),\n\t\tbgRedBright: f(\"\\x1b[101m\", \"\\x1b[49m\"),\n\t\tbgGreenBright: f(\"\\x1b[102m\", \"\\x1b[49m\"),\n\t\tbgYellowBright: f(\"\\x1b[103m\", \"\\x1b[49m\"),\n\t\tbgBlueBright: f(\"\\x1b[104m\", \"\\x1b[49m\"),\n\t\tbgMagentaBright: f(\"\\x1b[105m\", \"\\x1b[49m\"),\n\t\tbgCyanBright: f(\"\\x1b[106m\", \"\\x1b[49m\"),\n\t\tbgWhiteBright: f(\"\\x1b[107m\", \"\\x1b[49m\"),\n\t}\n}\n\nmodule.exports = createColors()\nmodule.exports.createColors = createColors\n","export const CACHE_FOLDER_NAME = '.cache'\nexport const CACHE_FILE_NAME = 'token.ts'\nexport const CACHE_TOKEN_FILE_PATH = `${CACHE_FOLDER_NAME}/${CACHE_FILE_NAME}`\nexport const CUSTOM_RELEASE_PREFIX = 'custom'\n","import type { IConfig } from '@/types'\nimport { resolve } from 'node:path'\nimport { CACHE_TOKEN_FILE_PATH } from '@/constant.ts'\n\nconst CURRENT_PATH = resolve(import.meta.dirname, '../')\nexport const resolveConfig = async (): Promise<IConfig> => {\n const root = process.cwd()\n const tokenPath = resolve(CURRENT_PATH, `${CACHE_TOKEN_FILE_PATH}`)\n\n return {\n cwd: CURRENT_PATH,\n root,\n tokenFile: tokenPath,\n token: '',\n }\n}\n","import type { IConfig } from '@/types'\nimport { x } from 'tinyexec'\n\nexport const runCommand = async (config: IConfig, command: string, args: string[]) => {\n await x(command, args, {\n nodeOptions: {\n stdio: 'inherit',\n cwd: config.root,\n },\n })\n}\n","import fs from 'node:fs'\nimport boxen from 'boxen'\n\nexport const checkDirExist = (dirPath: string) => {\n return fs.existsSync(dirPath)\n}\n\nexport const createDir = (dirPath: string) => {\n if (!checkDirExist(dirPath)) {\n fs.mkdirSync(dirPath)\n }\n}\n\nexport const printWarning = (message: string) =>\n console.log(boxen(message, {\n title: 'Warning',\n padding: 1,\n borderStyle: 'round',\n borderColor: 'yellow',\n }))\n","import type { IConfig } from '@/types'\nimport { writeFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport { createJiti } from 'jiti'\nimport { CACHE_FOLDER_NAME } from '@/constant.ts'\nimport { createDir } from '@/utils.ts'\n\nexport const setToken = async (config: IConfig, token: string): Promise<void> => {\n createDir(resolve(config.cwd, CACHE_FOLDER_NAME))\n await writeFile(config.tokenFile, `export default \"${token}\"`)\n}\n\nexport const loaderToken = async (config: IConfig): Promise<string> => {\n const loader = createJiti(config.cwd)\n return await loader.import(config.tokenFile, { default: true })\n}\n","import type { IConfig } from '@/types'\nimport * as process from 'node:process'\nimport { cancel, isCancel, select, text } from '@clack/prompts'\nimport pc from 'picocolors'\nimport { CUSTOM_RELEASE_PREFIX } from '@/constant.ts'\n\n// https://semver.org/\n\nconst PADDING = 13\n\nexport const promptForNewVersion = async (config: IConfig) => {\n let custom: string = ''\n const release = await select({\n message: 'Current version 0.0.0',\n options: [\n { value: 'major', label: `${'major'.padStart(PADDING, ' ')} 0.0.0` },\n { value: 'minor', label: `${'minor'.padStart(PADDING, ' ')} 0.0.0` },\n { value: 'patch', label: `${'patch'.padStart(PADDING, ' ')} 0.0.0` },\n { value: 'next', label: `${'next'.padStart(PADDING, ' ')} 0.0.0` },\n { value: 'rc', label: `${'rc'.padStart(PADDING, ' ')} 0.0.0-${pc.green('rc')}.1` },\n { value: 'pre-beta-major', label: `${'pre-major'.padStart(PADDING, ' ')} 0.0.0-${pc.magenta('beta')}.1` },\n { value: 'pre-beta-minor', label: `${'pre-minor'.padStart(PADDING, ' ')} 0.0.0-${pc.magenta('beta')}.1` },\n { value: 'pre-beta-patch', label: `${'pre-patch'.padStart(PADDING, ' ')} 0.0.0-${pc.magenta('beta')}.1` },\n { value: 'pre-beta', label: `${'pre-beta'.padStart(PADDING, ' ')} 0.0.0-${pc.magenta('beta')}` },\n { value: 'pre-alpha-major', label: `${'alpha'.padStart(PADDING, ' ')} 0.0.0-${pc.yellow('alpha')}.beta` },\n { value: 'pre-alpha-minor', label: `${'alpha'.padStart(PADDING, ' ')} 0.0.0-${pc.yellow('alpha')}.1` },\n { value: 'pre-alpha-patch', label: `${'alpha'.padStart(PADDING, ' ')} 0.0.0-${pc.yellow('alpha')}` },\n { value: CUSTOM_RELEASE_PREFIX, label: `${'custom'.padStart(PADDING, ' ')} ...` },\n ],\n initialValue: 'next',\n })\n\n if (isCancel(release)) {\n cancel('No version selected')\n return process.exit(0)\n }\n\n if (release === CUSTOM_RELEASE_PREFIX) {\n custom = await text({\n message: 'Enter the new version number',\n placeholder: 'e.g. major, minor, patch, pre-alpha, pre-beta, rc, ...',\n }) as string\n\n if (isCancel(custom)) {\n cancel('No version enter')\n return process.exit(0)\n }\n }\n console.log({\n release,\n custom,\n })\n}\n","","import { intro, outro } from '@clack/prompts'\nimport cac from 'cac'\nimport pc from 'picocolors'\nimport { resolveConfig } from '@/config.ts'\nimport { runCommand } from '@/runCommand.ts'\nimport { loaderToken, setToken } from '@/token.ts'\nimport { printWarning } from '@/utils.ts'\nimport { promptForNewVersion } from '@/version.ts'\nimport { name, version } from '../package.json'\n\nconst cli = cac(name)\n\n// TODO 完成主目录下的 package.json 版本发布\n// TODO 完成 monorepo 相关版本,多选版本发布\n\ncli.command('')\n .action(async (options) => {\n const config = await resolveConfig()\n config.token = await loaderToken(config)\n console.log(config)\n console.log(import.meta)\n // await setToken(config, 'asdasdasd')\n // console.log(await loaderToken(config))\n\n intro(pc.bgCyan(` dnmp ${version} `))\n\n await promptForNewVersion(config)\n\n console.log('npm', [\n 'publish',\n `--//registry.npmjs.org/:_authToken=${config.token}`,\n '--access',\n 'public',\n ].join(' '))\n\n await runCommand(config, 'npm', [\n 'publish',\n `--//registry.npmjs.org/:_authToken=${config.token}`,\n '--access',\n 'public',\n ])\n\n outro('Done.')\n })\n\ncli.command('set <token>', 'Set the local release Token')\n .action(async (token: string = '') => {\n try {\n const config = await resolveConfig()\n await setToken(config, token)\n }\n catch (error: any) {\n printWarning(error.message)\n process.exit(1)\n }\n })\n\ncli.help()\ncli.version(version)\n\ntry {\n cli.parse()\n}\ncatch (error: any) {\n printWarning(error.message)\n process.exit(1)\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAA,IAAI,IAAI,WAAW,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;CAC7D,IAAI,mBACH,EAAE,CAAC,CAAC,IAAI,YAAY,KAAK,SAAS,aAAa,MAC9C,CAAC,CAAC,IAAI,eAAe,KAAK,SAAS,UAAU,IAAI,EAAE,aAAa,YAAa,EAAE,UAAU,EAAE,EAAE,SAAS,IAAI,SAAS,UAAW,CAAC,CAAC,IAAI;CAEtI,IAAI,aAAa,MAAM,OAAO,UAAU,UACvC,UAAS;EACR,IAAI,SAAS,KAAK,OAAO,QAAQ,OAAO,QAAQ,OAAO,KAAK,OAAO;AACnE,SAAO,CAAC,QAAQ,OAAO,aAAa,QAAQ,OAAO,SAAS,MAAM,GAAG,QAAQ,OAAO,SAAS;;CAG/F,IAAI,gBAAgB,QAAQ,OAAO,SAAS,UAAU;EACrD,IAAI,SAAS,IAAI,SAAS;AAC1B,KAAG;AACF,aAAU,OAAO,UAAU,QAAQ,MA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
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dnmp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-alpha.0.
|
|
4
|
+
"version": "0.0.0-alpha.0.2",
|
|
5
5
|
"packageManager": "pnpm@10.15.1",
|
|
6
6
|
"description": "Interactive CLI that bumps your version numbers and more",
|
|
7
7
|
"author": "lonewolfyx <olddrivero.king@qq.com>",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"module": "./dist/index.mjs",
|
|
20
20
|
"types": "./dist/index.d.mts",
|
|
21
21
|
"bin": {
|
|
22
|
-
"
|
|
22
|
+
"dnmp": "./bin/cli.js"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist"
|
|
@@ -29,23 +29,29 @@
|
|
|
29
29
|
"build": "tsdown",
|
|
30
30
|
"lint": "eslint",
|
|
31
31
|
"lint:fix": "eslint --fix",
|
|
32
|
-
"prepublishOnly": "pnpm build"
|
|
32
|
+
"prepublishOnly": "pnpm build",
|
|
33
|
+
"prepare": "simple-git-hooks"
|
|
33
34
|
},
|
|
34
35
|
"publishConfig": {
|
|
35
36
|
"registry": "https://registry.npmjs.org",
|
|
36
37
|
"access": "public"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
40
|
+
"@clack/prompts": "^0.11.0",
|
|
41
|
+
"boxen": "^8.0.1",
|
|
39
42
|
"cac": "^6.7.14",
|
|
40
43
|
"defu": "^6.1.4",
|
|
41
44
|
"find-up": "^8.0.0",
|
|
42
45
|
"glob": "^13.0.0",
|
|
43
|
-
"jiti": "^2.6.1"
|
|
46
|
+
"jiti": "^2.6.1",
|
|
47
|
+
"semver": "^7.7.3",
|
|
48
|
+
"tinyexec": "^1.0.2"
|
|
44
49
|
},
|
|
45
50
|
"devDependencies": {
|
|
46
51
|
"@antfu/eslint-config": "^6.7.3",
|
|
47
52
|
"@lonewolfyx/tsconfig": "^0.0.6",
|
|
48
53
|
"@types/node": "^25.0.3",
|
|
54
|
+
"@types/semver": "^7.7.1",
|
|
49
55
|
"eslint": "^9.39.2",
|
|
50
56
|
"lint-staged": "^16.2.7",
|
|
51
57
|
"picocolors": "^1.1.1",
|
package/dist/index.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import cac from "cac";
|
|
2
|
-
|
|
3
|
-
//#region package.json
|
|
4
|
-
var name = "dnmp";
|
|
5
|
-
var version = "0.0.0-alpha.0.1";
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/cli.ts
|
|
9
|
-
const cli = cac(name);
|
|
10
|
-
cli.command("").option("--test -t", "arg description", { default: false }).action(() => {});
|
|
11
|
-
cli.help();
|
|
12
|
-
cli.version(version);
|
|
13
|
-
cli.parse();
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { };
|
|
17
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../package.json","../src/cli.ts"],"sourcesContent":["","import cac from 'cac'\nimport { name, version } from '../package.json'\n\nconst cli = cac(name)\n\ncli.command('')\n .option('--test -t', 'arg description', { default: false })\n .action(() => {\n })\n\ncli.help()\ncli.version(version)\ncli.parse()\n"],"mappings":";;;;;;;;ACGA,MAAM,MAAM,IAAI,KAAK;AAErB,IAAI,QAAQ,GAAG,CACV,OAAO,aAAa,mBAAmB,EAAE,SAAS,OAAO,CAAC,CAC1D,aAAa,GACZ;AAEN,IAAI,MAAM;AACV,IAAI,QAAQ,QAAQ;AACpB,IAAI,OAAO"}
|
|
File without changes
|