@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 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();
@@ -0,0 +1,3 @@
1
+ # Auto Generate
2
+
3
+ generate by @lntvow/dev
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/dev",
3
- "version": "3.4.5",
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
- "script",
16
- "script/tmp/*"
15
+ "dist"
17
16
  ],
17
+ "bin": {
18
+ "lntvow": "./dist/cli.mjs"
19
+ },
18
20
  "dependencies": {
19
- "@commitlint/cli": "^19.3.0",
20
- "@commitlint/config-conventional": "^19.2.2",
21
- "@lntvow/eslint-config": "^9.17.6",
22
- "bumpp": "^9.4.1",
23
- "commitizen": "^4.3.0",
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
- "lint-staged": "^15.2.5",
26
- "rimraf": "^5.0.7",
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
- "dayjs": "^1.11.13"
35
+ "tsx": "^4.19.2",
36
+ "unbuild": "^3.3.1"
31
37
  },
32
38
  "scripts": {
33
- "postinstall": "node ./script/postinstall.js",
34
- "install": "node -e \"console.log('Running install script')\"",
35
- "type-check": "tsc --noEmit",
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 --commit --no-tag --push"
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
  }
@@ -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)
@@ -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 配置写入成功')
@@ -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
@@ -1,5 +0,0 @@
1
- shamefully-hoist=true
2
- auto-install-peers=true
3
-
4
- registry=https://registry.npmmirror.com
5
- # registry=https://registry.npmjs.org
@@ -1 +0,0 @@
1
- # 自动生成
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes