cmyr-template-cli 1.43.0 → 1.43.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/dist/plopfile.js
CHANGED
|
@@ -996,7 +996,7 @@ async function initDocker(projectPath, answers) {
|
|
|
996
996
|
if (!await import_fs_extra6.default.pathExists(scriptsDir)) {
|
|
997
997
|
await import_fs_extra6.default.mkdir(scriptsDir);
|
|
998
998
|
}
|
|
999
|
-
await copyFilesFromTemplates(projectPath, ["scripts/minify-docker.
|
|
999
|
+
await copyFilesFromTemplates(projectPath, ["scripts/minify-docker.mjs"]);
|
|
1000
1000
|
}
|
|
1001
1001
|
break;
|
|
1002
1002
|
default:
|
|
@@ -2277,7 +2277,7 @@ async function init(projectPath, answers) {
|
|
|
2277
2277
|
await asyncExec("git add .", {
|
|
2278
2278
|
cwd: projectPath
|
|
2279
2279
|
});
|
|
2280
|
-
await asyncExec('git commit -m "chore: init" --no-gpg', {
|
|
2280
|
+
await asyncExec('git commit -m "chore: init" --no-gpg --no-verify', {
|
|
2281
2281
|
cwd: projectPath
|
|
2282
2282
|
});
|
|
2283
2283
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cmyr-template-cli",
|
|
3
|
-
"version": "1.43.
|
|
3
|
+
"version": "1.43.2",
|
|
4
4
|
"description": "草梅友仁自制的项目模板创建器",
|
|
5
5
|
"author": "CaoMeiYouRen",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"ejs": "^3.1.6",
|
|
77
77
|
"fs-extra": "^11.0.0",
|
|
78
78
|
"json5": "^2.2.1",
|
|
79
|
-
"libsodium-wrappers": "
|
|
79
|
+
"libsodium-wrappers": "0.7.15",
|
|
80
80
|
"lodash": "^4.17.20",
|
|
81
81
|
"minimist": "^1.2.5",
|
|
82
82
|
"ora": "^5.4.1",
|
package/templates/Dockerfile
CHANGED
|
@@ -28,7 +28,7 @@ RUN pnpm add @vercel/nft@0.24.4 fs-extra@11.2.0 --save-prod
|
|
|
28
28
|
COPY --from=builder /app /app
|
|
29
29
|
|
|
30
30
|
RUN export PROJECT_ROOT=/app/ && \
|
|
31
|
-
node /app/scripts/minify-docker.
|
|
31
|
+
node /app/scripts/minify-docker.mjs && \
|
|
32
32
|
rm -rf /app/node_modules /app/scripts && \
|
|
33
33
|
mv /app/app-minimal/node_modules /app/ && \
|
|
34
34
|
rm -rf /app/app-minimal
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import fs from 'fs-extra'
|
|
3
|
+
import { nodeFileTrace } from '@vercel/nft'
|
|
4
|
+
const __dirname = import.meta.dirname
|
|
5
|
+
// !!! if any new dependencies are added, update the Dockerfile !!!
|
|
6
|
+
|
|
7
|
+
const projectRoot = path.resolve(process.env.PROJECT_ROOT || path.join(__dirname, '../..'))
|
|
8
|
+
const resultFolder = path.join(projectRoot, 'app-minimal') // no need to resolve, ProjectRoot is always absolute
|
|
9
|
+
const pkg = await fs.readJSON(path.join(projectRoot, 'package.json'))
|
|
10
|
+
|
|
11
|
+
let mainPath = ''
|
|
12
|
+
const mainPaths = [pkg.main, 'dist/index.js', 'dist/main.js']
|
|
13
|
+
for (const key of mainPaths) {
|
|
14
|
+
const fullPath = path.join(projectRoot, key)
|
|
15
|
+
if (await fs.pathExists(fullPath)) {
|
|
16
|
+
mainPath = fullPath
|
|
17
|
+
break
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (!mainPath) {
|
|
21
|
+
process.exit(1)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log('Start analyzing, project root:', projectRoot)
|
|
25
|
+
const files = [mainPath]
|
|
26
|
+
const { fileList: fileSet } = await nodeFileTrace(files, {
|
|
27
|
+
base: projectRoot,
|
|
28
|
+
})
|
|
29
|
+
let fileList = [...fileSet]
|
|
30
|
+
console.log('Total touchable files:', fileList.length)
|
|
31
|
+
fileList = fileList.filter((file) => file.startsWith('node_modules')) // only need node_modules
|
|
32
|
+
console.log('Total files need to be copied (touchable files in node_modules/):', fileList.length)
|
|
33
|
+
console.log('Start copying files, destination:', resultFolder)
|
|
34
|
+
await Promise.all(fileList.map((e) => fs.copy(path.join(projectRoot, e), path.join(resultFolder, e)))).catch((error) => {
|
|
35
|
+
// fix unhandled promise rejections
|
|
36
|
+
console.error(error, error.stack)
|
|
37
|
+
process.exit(1)
|
|
38
|
+
})
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const fs = require('fs-extra')
|
|
3
|
-
const { nodeFileTrace } = require('@vercel/nft');
|
|
4
|
-
// !!! if any new dependencies are added, update the Dockerfile !!!
|
|
5
|
-
|
|
6
|
-
(async () => {
|
|
7
|
-
const projectRoot = path.resolve(process.env.PROJECT_ROOT || path.join(__dirname, '../'))
|
|
8
|
-
const resultFolder = path.join(projectRoot, 'app-minimal') // no need to resolve, ProjectRoot is always absolute
|
|
9
|
-
const pkg = await fs.readJSON(path.join(projectRoot, 'package.json'))
|
|
10
|
-
|
|
11
|
-
let mainPath = ''
|
|
12
|
-
const mainPaths = [pkg.main, 'dist/index.js', 'dist/main.js']
|
|
13
|
-
for (const key of mainPaths) {
|
|
14
|
-
const fullPath = path.join(projectRoot, key)
|
|
15
|
-
if (await fs.pathExists(fullPath)) {
|
|
16
|
-
mainPath = fullPath
|
|
17
|
-
break
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (!mainPath) {
|
|
21
|
-
process.exit(1)
|
|
22
|
-
}
|
|
23
|
-
const files = [mainPath]
|
|
24
|
-
console.log('Start analyzing, project root:', projectRoot)
|
|
25
|
-
const { fileList: fileSet } = await nodeFileTrace(files, {
|
|
26
|
-
base: projectRoot,
|
|
27
|
-
paths: {
|
|
28
|
-
'@/': 'dist/',
|
|
29
|
-
},
|
|
30
|
-
})
|
|
31
|
-
let fileList = Array.from(fileSet)
|
|
32
|
-
console.log('Total touchable files:', fileList.length)
|
|
33
|
-
fileList = fileList.filter((file) => file.startsWith('node_modules')) // only need node_modules
|
|
34
|
-
console.log('Total files need to be copied (touchable files in node_modules):', fileList.length)
|
|
35
|
-
console.log('Start copying files, destination:', resultFolder)
|
|
36
|
-
return Promise.all(fileList.map((e) => fs.copy(path.join(projectRoot, e), path.join(resultFolder, e)).catch(console.error),
|
|
37
|
-
))
|
|
38
|
-
})().catch((err) => {
|
|
39
|
-
// fix unhandled promise rejections
|
|
40
|
-
console.error(err, err.stack)
|
|
41
|
-
process.exit(1)
|
|
42
|
-
})
|