create-pnpm-cli 0.0.1 → 0.0.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/bin/bin.js +3 -0
- package/lib/cli.d.ts +5 -0
- package/lib/cli.js +63 -0
- package/package.json +26 -9
- package/template/pnpm-typescript-monorepo/README.md +1 -0
- package/template/pnpm-typescript-monorepo/apps/examples/package.json +10 -0
- package/template/pnpm-typescript-monorepo/package.json +15 -0
- package/template/pnpm-typescript-monorepo/packages/name/bin/bin.js +3 -0
- package/template/pnpm-typescript-monorepo/packages/name/package.json +15 -0
- package/template/pnpm-typescript-monorepo/pnpm-workspace.yaml +3 -0
- package/template/pnpm-typescript-monorepo/prettier.config.cjs +10 -0
- package/template/todo-react-typescript/README.md +1 -0
package/bin/bin.js
ADDED
package/lib/cli.d.ts
ADDED
package/lib/cli.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/tsup@8.2.3_typescript@5.5.4/node_modules/tsup/assets/esm_shims.js
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import path from "path";
|
|
4
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
5
|
+
var getDirname = () => path.dirname(getFilename());
|
|
6
|
+
var __dirname = /* @__PURE__ */ getDirname();
|
|
7
|
+
|
|
8
|
+
// package.json
|
|
9
|
+
var version = "0.0.2";
|
|
10
|
+
|
|
11
|
+
// src/constants.ts
|
|
12
|
+
import path2 from "path";
|
|
13
|
+
var ROOT_PATH = path2.join(__dirname, "..");
|
|
14
|
+
var TEMPLATE_PATH = path2.join(ROOT_PATH, "template");
|
|
15
|
+
var PACKAGE_CHOICES = [
|
|
16
|
+
"prettier" /* prettier */
|
|
17
|
+
].map((item) => ({ name: item, value: item }));
|
|
18
|
+
var PACKAGE_MAP = {
|
|
19
|
+
["prettier" /* prettier */]: {
|
|
20
|
+
packages: ["prettier", "@trivago/prettier-plugin-sort-imports"],
|
|
21
|
+
options: ["--save-dev"]
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/utils.ts
|
|
26
|
+
import { exit } from "process";
|
|
27
|
+
function handleError(err, message) {
|
|
28
|
+
console.log(message + "\uFF1A", err);
|
|
29
|
+
exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/cli.ts
|
|
33
|
+
import { input, select } from "@inquirer/prompts";
|
|
34
|
+
import { program } from "commander";
|
|
35
|
+
import glob from "fast-glob";
|
|
36
|
+
import fse from "fs-extra";
|
|
37
|
+
import packageManagerInstall from "package-manager-install";
|
|
38
|
+
import path3 from "path";
|
|
39
|
+
var cli = program;
|
|
40
|
+
cli.name("create-pnpm-cli").version(version);
|
|
41
|
+
cli.command("create", { isDefault: true }).description("create pnpm cli").argument("[path]", "path to mkdir", "./").action(async (targetPath) => {
|
|
42
|
+
const names = await glob(`**`, {
|
|
43
|
+
deep: 1,
|
|
44
|
+
cwd: TEMPLATE_PATH,
|
|
45
|
+
onlyFiles: false
|
|
46
|
+
});
|
|
47
|
+
const template = await select({
|
|
48
|
+
message: "\u8BF7\u9009\u62E9\u6A21\u677F",
|
|
49
|
+
choices: names.map((item) => ({ name: item, value: item }))
|
|
50
|
+
});
|
|
51
|
+
const name = await input({
|
|
52
|
+
message: "\u8BF7\u8F93\u5165\u5305\u540D",
|
|
53
|
+
default: template
|
|
54
|
+
});
|
|
55
|
+
const target = path3.join(targetPath, name);
|
|
56
|
+
await fse.ensureDir(target).catch((err) => handleError(err, "\u6587\u4EF6\u5939\u4E0D\u5B58\u5728"));
|
|
57
|
+
await fse.copy(path3.join(TEMPLATE_PATH, template), target).catch((err) => handleError(err, "\u62F7\u8D1D\u6587\u4EF6\u9519\u8BEF"));
|
|
58
|
+
await packageManagerInstall({ cwd: target });
|
|
59
|
+
});
|
|
60
|
+
cli.parse();
|
|
61
|
+
export {
|
|
62
|
+
cli
|
|
63
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pnpm-cli",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "create pnpm cli",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./lib/cli.js",
|
|
7
|
+
"module": "./lib/cli.js",
|
|
8
|
+
"types": "./lib/cli.d.ts",
|
|
9
|
+
"bin": "./bin/bin.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"./lib",
|
|
12
|
+
"./bin",
|
|
13
|
+
"template"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@inquirer/prompts": "^5.3.6",
|
|
17
|
+
"commander": "^11.1.0",
|
|
18
|
+
"fast-glob": "^3.3.2",
|
|
19
|
+
"fs-extra": "^11.2.0",
|
|
20
|
+
"package-manager-install": "^0.0.6"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/fs-extra": "^11.0.4",
|
|
24
|
+
"tsup": "^8.2.3"
|
|
8
25
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "tsup ./src/cli.ts --dts --clean --shims --format=esm --platform=node --outDir=./lib --watch"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# README
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scripts": {
|
|
3
|
+
"dev": "pnpm --recursive --parallel --filter=./packages/** dev",
|
|
4
|
+
"build": "pnpm --recursive --filter=./packages/** build"
|
|
5
|
+
},
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
8
|
+
"@types/node": "^20.10.5",
|
|
9
|
+
"prettier": "^3.2.4",
|
|
10
|
+
"typescript": "^5.2.2"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC"
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "name",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "package",
|
|
5
|
+
"scripts": {},
|
|
6
|
+
"main": "./lib/index.js",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
8
|
+
"bin": "./bin/bin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"./lib",
|
|
11
|
+
"./bin"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {},
|
|
14
|
+
"devDependencies": {}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# README
|