@lntvow/dev 3.0.4 → 3.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/dev",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "type": "module",
5
5
  "description": "开发环境依赖包",
6
6
  "keywords": [
@@ -1,14 +1,33 @@
1
- /* eslint-disable no-console */
2
- import { exec } from 'node:child_process'
3
- import fs from 'node:fs'
1
+ import fs, { appendFileSync } from 'node:fs'
4
2
  import path from 'node:path'
5
3
  import { fileURLToPath } from 'node:url'
4
+ import { exec } from 'node:child_process'
5
+ import dayjs from 'dayjs'
6
+ import utc from 'dayjs/plugin/utc.js'
7
+ import timezone from 'dayjs/plugin/timezone.js'
8
+
9
+ dayjs.extend(timezone)
10
+ dayjs.extend(utc)
11
+
12
+ const n = {
13
+ log: str => {
14
+ const time = dayjs().tz('Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss')
15
+
16
+ // appendFileSync(examplePath, `${time}: ${str}\n`)
17
+ },
18
+ }
6
19
 
7
20
  const __filename = fileURLToPath(import.meta.url)
8
21
  const __dirname = path.dirname(__filename)
9
22
 
10
23
  const [cwd] = process.cwd().split('node_modules')
11
24
 
25
+ const examplePath = path.resolve(cwd, `./lntvow.dev.log.${dayjs().tz('Asia/Shanghai').format('YYYY-MM-DD_HH-mm-ss')}`)
26
+ // 创建文件
27
+ // fs.writeFileSync(examplePath, '')
28
+
29
+ n.log('postinstall 开始执行')
30
+
12
31
  function copyDirectorySync(source, target) {
13
32
  // 创建目标目录(如果不存在)
14
33
  if (!fs.existsSync(target)) {
@@ -31,7 +50,6 @@ function copyDirectorySync(source, target) {
31
50
 
32
51
  // 如果是文件,使用流复制
33
52
  fs.createReadStream(sourcePath).pipe(fs.createWriteStream(filePath))
34
- console.log(`文件复制成功: ${sourcePath}`)
35
53
  }
36
54
  })
37
55
  }
@@ -39,15 +57,19 @@ function copyDirectorySync(source, target) {
39
57
  // 复制模板文件
40
58
  copyDirectorySync(path.resolve(__dirname, './tmp'), cwd)
41
59
 
42
- // 创建文件
43
- fs.writeFileSync(path.resolve(__dirname, './example.text'), 'Hello, World!', 'utf8')
60
+ n.log('postinstall 文件复制完毕')
61
+
62
+ n.log('开始执行 npx simple-git-hooks')
44
63
 
45
64
  // 初始化
46
65
  exec('npx simple-git-hooks', { cwd }, (err, str) => {
47
- console.log('npx simple-git-hooks')
66
+ n.log('执行成功 npx simple-git-hooks')
67
+
48
68
  if (err) {
49
- console.log('npx simple-git-hooks err', err)
69
+ n.log('npx simple-git-hooks 执行失败')
50
70
  } else {
51
- console.log(str)
71
+ n.log('npx simple-git-hooks 执行成功')
72
+ n.log(str)
73
+ //
52
74
  }
53
75
  })