@lightnet/cli 4.3.0 → 4.4.0
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/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/src/check-files.js +5 -4
- package/src/check-translations.js +25 -8
- package/src/index.js +5 -3
- package/src/support/cli-config.js +1 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @lightnet/cli
|
|
2
2
|
|
|
3
|
+
## 4.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#429](https://github.com/LightNetDev/LightNet/pull/429) [`00faa68`](https://github.com/LightNetDev/LightNet/commit/00faa6806bbdb74aef665d71b813449f2a15137f) - Add `check-translations --no-build` and `check-translations --build` support and improve CLI check commands.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#429](https://github.com/LightNetDev/LightNet/pull/429) [`00faa68`](https://github.com/LightNetDev/LightNet/commit/00faa6806bbdb74aef665d71b813449f2a15137f) - Rename `check-files --yes` to `check-files --no-confirm` for clearer unattended deletion.
|
|
12
|
+
|
|
3
13
|
## 4.3.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/package.json
CHANGED
package/src/check-files.js
CHANGED
|
@@ -25,7 +25,7 @@ const categoryImagesDir = "src/content/categories/images"
|
|
|
25
25
|
* @typedef {{
|
|
26
26
|
* scope?: string
|
|
27
27
|
* fix?: boolean
|
|
28
|
-
*
|
|
28
|
+
* confirm?: boolean
|
|
29
29
|
* r2?: boolean
|
|
30
30
|
* }} CheckFilesOptions
|
|
31
31
|
*/
|
|
@@ -185,13 +185,14 @@ export async function checkFiles(options, runtime = {}) {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
if (deletions.length > 0) {
|
|
188
|
-
|
|
188
|
+
const shouldSkipConfirmation = options.confirm === false
|
|
189
|
+
if (!shouldSkipConfirmation && !interactive) {
|
|
189
190
|
throw new CliError(
|
|
190
|
-
'Deletion requires confirmation. Re-run with "--fix --
|
|
191
|
+
'Deletion requires confirmation. Re-run with "--fix --no-confirm" in non-interactive environments.',
|
|
191
192
|
)
|
|
192
193
|
}
|
|
193
194
|
const shouldDelete =
|
|
194
|
-
|
|
195
|
+
shouldSkipConfirmation ||
|
|
195
196
|
(await confirmDeletion({
|
|
196
197
|
deletions,
|
|
197
198
|
promptConfirm,
|
|
@@ -22,6 +22,12 @@ import { confirm, intro, log, outro, taskLog } from "@clack/prompts"
|
|
|
22
22
|
* }} Languages
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {{
|
|
27
|
+
* build?: boolean
|
|
28
|
+
* }} CheckTranslationsOptions
|
|
29
|
+
*/
|
|
30
|
+
|
|
25
31
|
const lightnetCachePath = resolve(cwd(), "node_modules", ".cache", "lightnet")
|
|
26
32
|
|
|
27
33
|
/** @type {{type:Translation["type"], title:string, action:string}[]} */
|
|
@@ -44,14 +50,18 @@ const translationSources = [
|
|
|
44
50
|
},
|
|
45
51
|
]
|
|
46
52
|
|
|
47
|
-
|
|
53
|
+
/**
|
|
54
|
+
* @param {CheckTranslationsOptions} [options]
|
|
55
|
+
*/
|
|
56
|
+
export async function checkTranslations(options = {}) {
|
|
48
57
|
intro("check-translations")
|
|
49
58
|
|
|
50
|
-
const buildAvailable = await runBuild()
|
|
59
|
+
const buildAvailable = await runBuild(options.build)
|
|
51
60
|
if (!buildAvailable) {
|
|
52
61
|
outro("Build failed. 🚧")
|
|
53
62
|
return false
|
|
54
63
|
}
|
|
64
|
+
|
|
55
65
|
const translations = await readTranslations()
|
|
56
66
|
const languages = await readLanguages()
|
|
57
67
|
if (!translations || !languages || translations.length === 0) {
|
|
@@ -84,12 +94,19 @@ export async function checkTranslations() {
|
|
|
84
94
|
return false
|
|
85
95
|
}
|
|
86
96
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param {boolean|undefined} build
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
async function runBuild(build) {
|
|
103
|
+
const shouldRunBuild =
|
|
104
|
+
build ??
|
|
105
|
+
(await confirm({
|
|
106
|
+
message:
|
|
107
|
+
"Run pnpm build now? Command requires an up-to-date dist/ directory.",
|
|
108
|
+
initialValue: false,
|
|
109
|
+
}))
|
|
93
110
|
if (!shouldRunBuild) {
|
|
94
111
|
return true
|
|
95
112
|
}
|
package/src/index.js
CHANGED
|
@@ -21,8 +21,10 @@ program
|
|
|
21
21
|
program
|
|
22
22
|
.command("check-translations")
|
|
23
23
|
.description("check if last build has been missing any translations")
|
|
24
|
-
.
|
|
25
|
-
|
|
24
|
+
.option("--build", "run pnpm build before checking translations")
|
|
25
|
+
.option("--no-build", "skip the build prompt and use the latest dist/ output")
|
|
26
|
+
.action(async (options) => {
|
|
27
|
+
const checkSuccessful = await checkTranslations(options)
|
|
26
28
|
commandExitCode = checkSuccessful ? 0 : 1
|
|
27
29
|
})
|
|
28
30
|
|
|
@@ -32,7 +34,7 @@ program
|
|
|
32
34
|
"check for missing and orphaned content files and thumbnails in a LightNet site",
|
|
33
35
|
)
|
|
34
36
|
.option("--fix", "remove orphaned files")
|
|
35
|
-
.option("--
|
|
37
|
+
.option("--no-confirm", "skip deletion confirmation when used with --fix")
|
|
36
38
|
.option(
|
|
37
39
|
"--r2",
|
|
38
40
|
"validate remote content files in Cloudflare R2 instead of public/files",
|
|
@@ -6,9 +6,7 @@ import { resolve } from "node:path"
|
|
|
6
6
|
import { CliError } from "./cli-error.js"
|
|
7
7
|
import { pathExists } from "./filesystem.js"
|
|
8
8
|
|
|
9
|
-
export const cliConfigFileName = "
|
|
10
|
-
|
|
11
|
-
const gitIgnoreEntry = `${cliConfigFileName}\n`
|
|
9
|
+
export const cliConfigFileName = "lightnet-cli.json"
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* @param {string} cwd
|
|
@@ -36,22 +34,4 @@ export async function writeCliConfig(cwd, config) {
|
|
|
36
34
|
`${JSON.stringify(config, null, 2)}\n`,
|
|
37
35
|
"utf8",
|
|
38
36
|
)
|
|
39
|
-
await ensureGitignoreContainsConfig(cwd)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @param {string} cwd
|
|
44
|
-
*/
|
|
45
|
-
async function ensureGitignoreContainsConfig(cwd) {
|
|
46
|
-
const filePath = resolve(cwd, ".gitignore")
|
|
47
|
-
const contents = (await pathExists(filePath))
|
|
48
|
-
? await readFile(filePath, "utf8")
|
|
49
|
-
: ""
|
|
50
|
-
if (contents.includes(cliConfigFileName)) {
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
const next = contents
|
|
54
|
-
? `${contents}${contents.endsWith("\n") ? "" : "\n"}${gitIgnoreEntry}`
|
|
55
|
-
: gitIgnoreEntry
|
|
56
|
-
await writeFile(filePath, next, "utf8")
|
|
57
37
|
}
|