@lntvow/dev 3.4.5 → 4.0.1
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/dist/cli.cjs +90 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +78 -0
- package/dist/temp/README.md +3 -0
- package/package.json +23 -15
- package/script/postinstall.js +0 -44
- package/script/preinstall.js +0 -26
- package/script/tmp/.gitignore +0 -25
- package/script/tmp/.npmrc +0 -5
- package/script/tmp/README.md +0 -1
- /package/{script/tmp → dist/temp}/.commitlintrc +0 -0
- /package/{script/tmp → dist/temp}/.czrc +0 -0
- /package/{script/tmp → dist/temp}/.editorconfig +0 -0
- /package/{script/tmp → dist/temp}/.lintstagedrc +0 -0
- /package/{script/tmp → dist/temp}/.prettierrc +0 -0
- /package/{script/tmp → dist/temp}/.simple-git-hooks.json +0 -0
- /package/{script/tmp → dist/temp}/eslint.config.mjs +0 -0
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const child_process = require('child_process');
|
|
5
|
+
const fs$1 = require('fs');
|
|
6
|
+
const path$1 = require('path');
|
|
7
|
+
const commander = require('commander');
|
|
8
|
+
const pc = require('picocolors');
|
|
9
|
+
const fs = require('node:fs');
|
|
10
|
+
const path = require('node:path');
|
|
11
|
+
const node_url = require('node:url');
|
|
12
|
+
const dayjs = require('dayjs');
|
|
13
|
+
const utc = require('dayjs/plugin/utc.js');
|
|
14
|
+
const timezone = require('dayjs/plugin/timezone.js');
|
|
15
|
+
|
|
16
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
17
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
18
|
+
|
|
19
|
+
const pc__default = /*#__PURE__*/_interopDefaultCompat(pc);
|
|
20
|
+
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
21
|
+
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
22
|
+
const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
|
|
23
|
+
const utc__default = /*#__PURE__*/_interopDefaultCompat(utc);
|
|
24
|
+
const timezone__default = /*#__PURE__*/_interopDefaultCompat(timezone);
|
|
25
|
+
|
|
26
|
+
const name = "@lntvow/dev";
|
|
27
|
+
const version = "4.0.1";
|
|
28
|
+
|
|
29
|
+
dayjs__default.extend(timezone__default);
|
|
30
|
+
dayjs__default.extend(utc__default);
|
|
31
|
+
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
|
32
|
+
const __dirname$1 = path__default.dirname(__filename$1);
|
|
33
|
+
const [cwd] = process.cwd().split("node_modules");
|
|
34
|
+
console.log("cwd: ", cwd);
|
|
35
|
+
function copyDirectorySync(source, target) {
|
|
36
|
+
if (!fs__default.existsSync(target)) fs__default.mkdirSync(target);
|
|
37
|
+
const files = fs__default.readdirSync(source, { withFileTypes: true });
|
|
38
|
+
files.forEach((file) => {
|
|
39
|
+
const sourcePath = path__default.resolve(source, file.name);
|
|
40
|
+
const filePath = path__default.resolve(target, file.name);
|
|
41
|
+
if (file.isDirectory()) {
|
|
42
|
+
copyDirectorySync(sourcePath, filePath);
|
|
43
|
+
} else {
|
|
44
|
+
if (fs__default.existsSync(filePath)) return;
|
|
45
|
+
fs__default.copyFileSync(sourcePath, filePath);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function postinstall() {
|
|
50
|
+
console.log(pc__default.blue("Start copying template files"));
|
|
51
|
+
copyDirectorySync(path__default.resolve(__dirname$1, "./temp"), cwd);
|
|
52
|
+
console.log(pc__default.green("Template files copied successfully"));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
commander.program.name(name).version(version, "-v, --version", "output the version number");
|
|
56
|
+
commander.program.command("init").option("-t, --temp", "copy template files", true).option("--no-temp", "not copy template files").option("-g, --git", "init simple-git-hooks", true).option("--no-git", "not init simple-git-hooks").option("-s, --scripts", "init scripts", true).option("--no-scripts", "not init scripts").description("init project").action((options) => {
|
|
57
|
+
console.log(pc__default.green("Init project by @lntvow/dev"));
|
|
58
|
+
const { temp, git, scripts } = options;
|
|
59
|
+
if (temp) postinstall();
|
|
60
|
+
if (git) {
|
|
61
|
+
console.log(pc__default.blue("Start init simple-git-hooks"));
|
|
62
|
+
const output = child_process.execSync("npx simple-git-hooks");
|
|
63
|
+
console.log(output.toString());
|
|
64
|
+
}
|
|
65
|
+
if (scripts) {
|
|
66
|
+
console.log(pc__default.blue("Start init scripts"));
|
|
67
|
+
try {
|
|
68
|
+
const path = path$1.resolve(process.cwd(), "package.json");
|
|
69
|
+
let data = JSON.parse(fs$1.readFileSync(path, "utf-8"));
|
|
70
|
+
data = {
|
|
71
|
+
...data,
|
|
72
|
+
scripts: {
|
|
73
|
+
postinstall: "simple-git-hooks",
|
|
74
|
+
check: "tsc --noEmit",
|
|
75
|
+
lint: 'eslint "src/**/*.{js,jsx,ts,tsx,vue}"',
|
|
76
|
+
rimraf: "rimraf ./node_modules/",
|
|
77
|
+
commit: "git add . && git-cz && git push",
|
|
78
|
+
release: "git add . && bumpp package.json --all --no-tag",
|
|
79
|
+
...data.scripts
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
fs$1.writeFileSync(path, JSON.stringify(data, null, 2));
|
|
83
|
+
console.log(pc__default.green("Scripts added successfully"));
|
|
84
|
+
} catch {
|
|
85
|
+
console.log(pc__default.yellow("No package.json file found ignoring scripts"));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
console.log(pc__default.yellow('\nYou may need to re-execute the "pnpm install" command'));
|
|
89
|
+
});
|
|
90
|
+
commander.program.parse();
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
import { program } from 'commander';
|
|
6
|
+
import pc from 'picocolors';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import dayjs from 'dayjs';
|
|
11
|
+
import utc from 'dayjs/plugin/utc.js';
|
|
12
|
+
import timezone from 'dayjs/plugin/timezone.js';
|
|
13
|
+
|
|
14
|
+
const name = "@lntvow/dev";
|
|
15
|
+
const version = "4.0.1";
|
|
16
|
+
|
|
17
|
+
dayjs.extend(timezone);
|
|
18
|
+
dayjs.extend(utc);
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
const __dirname = path.dirname(__filename);
|
|
21
|
+
const [cwd] = process.cwd().split("node_modules");
|
|
22
|
+
console.log("cwd: ", cwd);
|
|
23
|
+
function copyDirectorySync(source, target) {
|
|
24
|
+
if (!fs.existsSync(target)) fs.mkdirSync(target);
|
|
25
|
+
const files = fs.readdirSync(source, { withFileTypes: true });
|
|
26
|
+
files.forEach((file) => {
|
|
27
|
+
const sourcePath = path.resolve(source, file.name);
|
|
28
|
+
const filePath = path.resolve(target, file.name);
|
|
29
|
+
if (file.isDirectory()) {
|
|
30
|
+
copyDirectorySync(sourcePath, filePath);
|
|
31
|
+
} else {
|
|
32
|
+
if (fs.existsSync(filePath)) return;
|
|
33
|
+
fs.copyFileSync(sourcePath, filePath);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function postinstall() {
|
|
38
|
+
console.log(pc.blue("Start copying template files"));
|
|
39
|
+
copyDirectorySync(path.resolve(__dirname, "./temp"), cwd);
|
|
40
|
+
console.log(pc.green("Template files copied successfully"));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
program.name(name).version(version, "-v, --version", "output the version number");
|
|
44
|
+
program.command("init").option("-t, --temp", "copy template files", true).option("--no-temp", "not copy template files").option("-g, --git", "init simple-git-hooks", true).option("--no-git", "not init simple-git-hooks").option("-s, --scripts", "init scripts", true).option("--no-scripts", "not init scripts").description("init project").action((options) => {
|
|
45
|
+
console.log(pc.green("Init project by @lntvow/dev"));
|
|
46
|
+
const { temp, git, scripts } = options;
|
|
47
|
+
if (temp) postinstall();
|
|
48
|
+
if (git) {
|
|
49
|
+
console.log(pc.blue("Start init simple-git-hooks"));
|
|
50
|
+
const output = execSync("npx simple-git-hooks");
|
|
51
|
+
console.log(output.toString());
|
|
52
|
+
}
|
|
53
|
+
if (scripts) {
|
|
54
|
+
console.log(pc.blue("Start init scripts"));
|
|
55
|
+
try {
|
|
56
|
+
const path = resolve(process.cwd(), "package.json");
|
|
57
|
+
let data = JSON.parse(readFileSync(path, "utf-8"));
|
|
58
|
+
data = {
|
|
59
|
+
...data,
|
|
60
|
+
scripts: {
|
|
61
|
+
postinstall: "simple-git-hooks",
|
|
62
|
+
check: "tsc --noEmit",
|
|
63
|
+
lint: 'eslint "src/**/*.{js,jsx,ts,tsx,vue}"',
|
|
64
|
+
rimraf: "rimraf ./node_modules/",
|
|
65
|
+
commit: "git add . && git-cz && git push",
|
|
66
|
+
release: "git add . && bumpp package.json --all --no-tag",
|
|
67
|
+
...data.scripts
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
writeFileSync(path, JSON.stringify(data, null, 2));
|
|
71
|
+
console.log(pc.green("Scripts added successfully"));
|
|
72
|
+
} catch {
|
|
73
|
+
console.log(pc.yellow("No package.json file found ignoring scripts"));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
console.log(pc.yellow('\nYou may need to re-execute the "pnpm install" command'));
|
|
77
|
+
});
|
|
78
|
+
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lntvow/dev",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "开发环境依赖包",
|
|
6
6
|
"keywords": [
|
|
@@ -12,29 +12,37 @@
|
|
|
12
12
|
"url": "https://github.com/lntvow/dev.git"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"
|
|
16
|
-
"script/tmp/*"
|
|
15
|
+
"dist"
|
|
17
16
|
],
|
|
17
|
+
"bin": {
|
|
18
|
+
"lntvow": "./dist/cli.mjs"
|
|
19
|
+
},
|
|
18
20
|
"dependencies": {
|
|
19
|
-
"@commitlint/cli": "^19.
|
|
20
|
-
"@commitlint/config-conventional": "^19.
|
|
21
|
-
"@lntvow/eslint-config": "^9.
|
|
22
|
-
"bumpp": "^
|
|
23
|
-
"
|
|
21
|
+
"@commitlint/cli": "^19.7.1",
|
|
22
|
+
"@commitlint/config-conventional": "^19.7.1",
|
|
23
|
+
"@lntvow/eslint-config": "^9.18.8",
|
|
24
|
+
"bumpp": "^8.0.1",
|
|
25
|
+
"commander": "^13.1.0",
|
|
26
|
+
"commitizen": "^4.3.1",
|
|
24
27
|
"cz-conventional-changelog": "^3.3.0",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
28
|
+
"dayjs": "^1.11.13",
|
|
29
|
+
"lint-staged": "^15.4.3",
|
|
30
|
+
"picocolors": "^1.1.1",
|
|
31
|
+
"rimraf": "^6.0.1",
|
|
27
32
|
"simple-git-hooks": "^2.11.1"
|
|
28
33
|
},
|
|
29
34
|
"devDependencies": {
|
|
30
|
-
"
|
|
35
|
+
"tsx": "^4.19.2",
|
|
36
|
+
"unbuild": "^3.3.1"
|
|
31
37
|
},
|
|
32
38
|
"scripts": {
|
|
33
|
-
"postinstall": "
|
|
34
|
-
"
|
|
35
|
-
"
|
|
39
|
+
"postinstall": "simple-git-hooks",
|
|
40
|
+
"check": "tsc --noEmit",
|
|
41
|
+
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx,vue}\"",
|
|
36
42
|
"rimraf": "rimraf ./node_modules/",
|
|
37
43
|
"commit": "git add . && git-cz && git push",
|
|
38
|
-
"release": "git add . && bumpp package.json --all --
|
|
44
|
+
"release": "git add . && bumpp package.json --all --no-tag",
|
|
45
|
+
"dev": "tsx src/cli.ts",
|
|
46
|
+
"build": "unbuild && tsx scripts/copy.ts"
|
|
39
47
|
}
|
|
40
48
|
}
|
package/script/postinstall.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import dayjs from 'dayjs'
|
|
5
|
-
import utc from 'dayjs/plugin/utc.js'
|
|
6
|
-
import timezone from 'dayjs/plugin/timezone.js'
|
|
7
|
-
|
|
8
|
-
dayjs.extend(timezone)
|
|
9
|
-
dayjs.extend(utc)
|
|
10
|
-
|
|
11
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
12
|
-
const __dirname = path.dirname(__filename)
|
|
13
|
-
|
|
14
|
-
const [cwd] = process.cwd().split('node_modules')
|
|
15
|
-
console.log('cwd: ', cwd)
|
|
16
|
-
|
|
17
|
-
function copyDirectorySync(source, target) {
|
|
18
|
-
// 创建目标目录(如果不存在)
|
|
19
|
-
if (!fs.existsSync(target)) {
|
|
20
|
-
fs.mkdirSync(target)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// 获取源目录下的所有文件和子目录
|
|
24
|
-
const files = fs.readdirSync(source, { withFileTypes: true })
|
|
25
|
-
|
|
26
|
-
// 遍历并复制文件和子目录
|
|
27
|
-
files.forEach(file => {
|
|
28
|
-
const sourcePath = path.resolve(source, file.name)
|
|
29
|
-
const filePath = path.resolve(target, file.name)
|
|
30
|
-
|
|
31
|
-
if (file.isDirectory()) {
|
|
32
|
-
// 如果是子目录,递归复制
|
|
33
|
-
copyDirectorySync(sourcePath, filePath)
|
|
34
|
-
} else {
|
|
35
|
-
if (fs.existsSync(filePath)) return
|
|
36
|
-
|
|
37
|
-
// 如果是文件,使用流复制
|
|
38
|
-
fs.createReadStream(sourcePath).pipe(fs.createWriteStream(filePath))
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
console.log('开始复制模板文件...')
|
|
43
|
-
// 复制模板文件
|
|
44
|
-
copyDirectorySync(path.resolve(__dirname, './tmp'), cwd)
|
package/script/preinstall.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
|
|
4
|
-
const cwd = process.cwd().split('node_modules')[0]
|
|
5
|
-
|
|
6
|
-
// 写入配置
|
|
7
|
-
const packageJson = fs.readFileSync(path.resolve(cwd, './package.json'), 'utf8')
|
|
8
|
-
const packageJsonObj = JSON.parse(packageJson)
|
|
9
|
-
|
|
10
|
-
if (!packageJsonObj.scripts) {
|
|
11
|
-
packageJsonObj.scripts = {}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
packageJsonObj.scripts = {
|
|
15
|
-
dev: 'vite --host',
|
|
16
|
-
'build:test': 'vite build --mode development',
|
|
17
|
-
'build:uat': 'vite build --mode uat',
|
|
18
|
-
'build:prod': 'vite build',
|
|
19
|
-
commit: 'git add . && git-cz && git push',
|
|
20
|
-
rimraf: 'rimraf ./node_modules/',
|
|
21
|
-
release: 'git add . && bumpp package.json --all --commit --no-tag --push',
|
|
22
|
-
...packageJsonObj.scripts,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
fs.writeFileSync(path.resolve(cwd, './package.json'), `${JSON.stringify(packageJsonObj, null, 2)}\n`)
|
|
26
|
-
console.log('lint-staged 配置写入成功')
|
package/script/tmp/.gitignore
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Logs
|
|
2
|
-
logs
|
|
3
|
-
*.log
|
|
4
|
-
npm-debug.log*
|
|
5
|
-
yarn-debug.log*
|
|
6
|
-
yarn-error.log*
|
|
7
|
-
pnpm-debug.log*
|
|
8
|
-
lerna-debug.log*
|
|
9
|
-
|
|
10
|
-
# Editor directories and files
|
|
11
|
-
*.suo
|
|
12
|
-
*.ntvs*
|
|
13
|
-
*.njsproj
|
|
14
|
-
*.sln
|
|
15
|
-
*.sw?
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#
|
|
19
|
-
node_modules
|
|
20
|
-
.DS_Store
|
|
21
|
-
dist
|
|
22
|
-
dist-ssr
|
|
23
|
-
coverage
|
|
24
|
-
*.local
|
|
25
|
-
_*
|
package/script/tmp/.npmrc
DELETED
package/script/tmp/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# 自动生成
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|