@meith/cli 0.17.1 → 0.18.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/LICENSE.md +21 -165
- package/bin/community.mjs +6 -4
- package/package.json +14 -14
- package/src/backup.ts +85 -32
- package/src/board-eject.ts +141 -6
- package/src/index.ts +19 -0
- package/src/plugin-manifest.ts +104 -39
- package/src/redaction.ts +4 -0
- package/src/upgrade.ts +1 -1
package/LICENSE.md
CHANGED
|
@@ -1,165 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
An "Application" is any work that makes use of an interface provided
|
|
23
|
-
by the Library, but which is not otherwise based on the Library.
|
|
24
|
-
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
-
of using an interface provided by the Library.
|
|
26
|
-
|
|
27
|
-
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
-
Application with the Library. The particular version of the Library
|
|
29
|
-
with which the Combined Work was made is also called the "Linked
|
|
30
|
-
Version".
|
|
31
|
-
|
|
32
|
-
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
-
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
-
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
-
based on the Application, and not on the Linked Version.
|
|
36
|
-
|
|
37
|
-
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
-
object code and/or source code for the Application, including any data
|
|
39
|
-
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
-
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
-
|
|
42
|
-
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
-
|
|
44
|
-
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
-
without being bound by section 3 of the GNU GPL.
|
|
46
|
-
|
|
47
|
-
2. Conveying Modified Versions.
|
|
48
|
-
|
|
49
|
-
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
-
facility refers to a function or data to be supplied by an Application
|
|
51
|
-
that uses the facility (other than as an argument passed when the
|
|
52
|
-
facility is invoked), then you may convey a copy of the modified
|
|
53
|
-
version:
|
|
54
|
-
|
|
55
|
-
a) under this License, provided that you make a good faith effort to
|
|
56
|
-
ensure that, in the event an Application does not supply the
|
|
57
|
-
function or data, the facility still operates, and performs
|
|
58
|
-
whatever part of its purpose remains meaningful, or
|
|
59
|
-
|
|
60
|
-
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
-
this License applicable to that copy.
|
|
62
|
-
|
|
63
|
-
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
-
|
|
65
|
-
The object code form of an Application may incorporate material from
|
|
66
|
-
a header file that is part of the Library. You may convey such object
|
|
67
|
-
code under terms of your choice, provided that, if the incorporated
|
|
68
|
-
material is not limited to numerical parameters, data structure
|
|
69
|
-
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
-
(ten or fewer lines in length), you do both of the following:
|
|
71
|
-
|
|
72
|
-
a) Give prominent notice with each copy of the object code that the
|
|
73
|
-
Library is used in it and that the Library and its use are
|
|
74
|
-
covered by this License.
|
|
75
|
-
|
|
76
|
-
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
-
document.
|
|
78
|
-
|
|
79
|
-
4. Combined Works.
|
|
80
|
-
|
|
81
|
-
You may convey a Combined Work under terms of your choice that,
|
|
82
|
-
taken together, effectively do not restrict modification of the
|
|
83
|
-
portions of the Library contained in the Combined Work and reverse
|
|
84
|
-
engineering for debugging such modifications, if you also do each of
|
|
85
|
-
the following:
|
|
86
|
-
|
|
87
|
-
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
-
the Library is used in it and that the Library and its use are
|
|
89
|
-
covered by this License.
|
|
90
|
-
|
|
91
|
-
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
-
document.
|
|
93
|
-
|
|
94
|
-
c) For a Combined Work that displays copyright notices during
|
|
95
|
-
execution, include the copyright notice for the Library among
|
|
96
|
-
these notices, as well as a reference directing the user to the
|
|
97
|
-
copies of the GNU GPL and this license document.
|
|
98
|
-
|
|
99
|
-
d) Do one of the following:
|
|
100
|
-
|
|
101
|
-
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
-
License, and the Corresponding Application Code in a form
|
|
103
|
-
suitable for, and under terms that permit, the user to
|
|
104
|
-
recombine or relink the Application with a modified version of
|
|
105
|
-
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
-
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
-
Corresponding Source.
|
|
108
|
-
|
|
109
|
-
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
-
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
-
a copy of the Library already present on the user's computer
|
|
112
|
-
system, and (b) will operate properly with a modified version
|
|
113
|
-
of the Library that is interface-compatible with the Linked
|
|
114
|
-
Version.
|
|
115
|
-
|
|
116
|
-
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
-
be required to provide such information under section 6 of the
|
|
118
|
-
GNU GPL, and only to the extent that such information is
|
|
119
|
-
necessary to install and execute a modified version of the
|
|
120
|
-
Combined Work produced by recombining or relinking the
|
|
121
|
-
Application with a modified version of the Linked Version. (If
|
|
122
|
-
you use option 4d0, the Installation Information must accompany
|
|
123
|
-
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
-
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
-
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
-
for conveying Corresponding Source.)
|
|
127
|
-
|
|
128
|
-
5. Combined Libraries.
|
|
129
|
-
|
|
130
|
-
You may place library facilities that are a work based on the
|
|
131
|
-
Library side by side in a single library together with other library
|
|
132
|
-
facilities that are not Applications and are not covered by this
|
|
133
|
-
License, and convey such a combined library under terms of your
|
|
134
|
-
choice, if you do both of the following:
|
|
135
|
-
|
|
136
|
-
a) Accompany the combined library with a copy of the same work based
|
|
137
|
-
on the Library, uncombined with any other library facilities,
|
|
138
|
-
conveyed under the terms of this License.
|
|
139
|
-
|
|
140
|
-
b) Give prominent notice with the combined library that part of it
|
|
141
|
-
is a work based on the Library, and explaining where to find the
|
|
142
|
-
accompanying uncombined form of the same work.
|
|
143
|
-
|
|
144
|
-
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
-
|
|
146
|
-
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
-
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
-
versions will be similar in spirit to the present version, but may
|
|
149
|
-
differ in detail to address new problems or concerns.
|
|
150
|
-
|
|
151
|
-
Each version is given a distinguishing version number. If the
|
|
152
|
-
Library as you received it specifies that a certain numbered version
|
|
153
|
-
of the GNU Lesser General Public License "or any later version"
|
|
154
|
-
applies to it, you have the option of following the terms and
|
|
155
|
-
conditions either of that published version or of any later version
|
|
156
|
-
published by the Free Software Foundation. If the Library as you
|
|
157
|
-
received it does not specify a version number of the GNU Lesser
|
|
158
|
-
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
-
General Public License ever published by the Free Software Foundation.
|
|
160
|
-
|
|
161
|
-
If the Library as you received it specifies that a proxy can decide
|
|
162
|
-
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
-
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
-
permanent authorization for you to choose that version for the
|
|
165
|
-
Library.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jordan Harrison and the Meith contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/community.mjs
CHANGED
|
@@ -92,11 +92,13 @@ function materialize() {
|
|
|
92
92
|
return join(srcTarget, 'index.ts')
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Resolved from this package's own directory — `tsx` is `@meith/cli`'s
|
|
97
|
+
* dependency, found either hoisted to the workspace root or nested under
|
|
98
|
+
* this package's own `node_modules`, the same reasoning as forum-web's
|
|
99
|
+
* `resolveNextBin()`.
|
|
100
|
+
*/
|
|
95
101
|
function resolveTsx() {
|
|
96
|
-
// Resolved from this package's own directory — `tsx` is @meith/cli's
|
|
97
|
-
// dependency, found either hoisted to the workspace root or nested under
|
|
98
|
-
// this package's own node_modules, the same reasoning as forum-web's
|
|
99
|
-
// resolveNextBin().
|
|
100
102
|
const require = createRequire(join(packageRoot, 'package.json'))
|
|
101
103
|
try {
|
|
102
104
|
return require.resolve('tsx/cli')
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meith/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "The operator CLI: migrations, backup and restore, imports, users and settings — and the community bin that runs it against an external board workspace.",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/meith-dev/meith.git",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"tsx": "^4.23.12",
|
|
26
|
-
"@meith/accounts": "0.
|
|
27
|
-
"@meith/core": "0.
|
|
28
|
-
"@meith/db": "0.
|
|
29
|
-
"@meith/demo": "0.
|
|
30
|
-
"@meith/forums": "0.
|
|
31
|
-
"@meith/drivers": "0.
|
|
32
|
-
"@meith/plugin-kit": "0.
|
|
33
|
-
"@meith/profile-fields": "0.
|
|
34
|
-
"@meith/settings": "0.
|
|
35
|
-
"
|
|
36
|
-
"@meith/
|
|
37
|
-
"
|
|
26
|
+
"@meith/accounts": "0.18.0",
|
|
27
|
+
"@meith/core": "0.18.0",
|
|
28
|
+
"@meith/db": "0.18.0",
|
|
29
|
+
"@meith/demo": "0.18.0",
|
|
30
|
+
"@meith/forums": "0.18.0",
|
|
31
|
+
"@meith/drivers": "0.18.0",
|
|
32
|
+
"@meith/plugin-kit": "0.18.0",
|
|
33
|
+
"@meith/profile-fields": "0.18.0",
|
|
34
|
+
"@meith/settings": "0.18.0",
|
|
35
|
+
"@meith/tasks": "0.18.0",
|
|
36
|
+
"@meith/runtime": "0.18.0",
|
|
37
|
+
"create-meith": "0.18.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"esbuild": "^0.28.2"
|
package/src/backup.ts
CHANGED
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
import { tmpdir } from 'node:os'
|
|
15
15
|
import path from 'node:path'
|
|
16
16
|
|
|
17
|
-
import { ConfigurationError, env, ValidationError } from '@meith/core'
|
|
17
|
+
import { ConfigurationError, env, type FileStore, ValidationError } from '@meith/core'
|
|
18
18
|
import { migrationUrl, runMigrations } from '@meith/db'
|
|
19
|
-
import { S3FileStore } from '@meith/drivers'
|
|
19
|
+
import { BlobFileStore, S3FileStore } from '@meith/drivers'
|
|
20
20
|
|
|
21
21
|
import { optional, parseFlags } from './args'
|
|
22
22
|
import { requirePostgres } from './context'
|
|
@@ -24,17 +24,19 @@ import { CODE_VERSION } from './upgrade'
|
|
|
24
24
|
|
|
25
25
|
export type UploadsMode = 'include' | 'skip'
|
|
26
26
|
|
|
27
|
+
export type FilestoreDriver = 'local' | 's3' | 'blob'
|
|
28
|
+
|
|
27
29
|
export interface BackupManifest {
|
|
28
30
|
readonly format: 1
|
|
29
31
|
readonly createdAt: string
|
|
30
32
|
readonly version: string
|
|
31
|
-
readonly filestore:
|
|
33
|
+
readonly filestore: FilestoreDriver
|
|
32
34
|
readonly uploads: 'included' | 'skipped'
|
|
33
35
|
readonly bucket?: string
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
export function resolveUploadsMode(driver:
|
|
37
|
-
if (flag === undefined) return driver === '
|
|
38
|
+
export function resolveUploadsMode(driver: FilestoreDriver, flag: string | undefined): UploadsMode {
|
|
39
|
+
if (flag === undefined) return driver === 's3' ? 'skip' : 'include'
|
|
38
40
|
if (flag === 'include' || flag === 'skip') return flag
|
|
39
41
|
throw new ValidationError(`--uploads must be "include" or "skip", got "${flag}".`)
|
|
40
42
|
}
|
|
@@ -67,7 +69,11 @@ export function parseManifest(raw: string): BackupManifest {
|
|
|
67
69
|
if (typeof manifest.createdAt !== 'string' || typeof manifest.version !== 'string') {
|
|
68
70
|
throw new ValidationError('The bundle manifest is missing createdAt or version.')
|
|
69
71
|
}
|
|
70
|
-
if (
|
|
72
|
+
if (
|
|
73
|
+
manifest.filestore !== 'local' &&
|
|
74
|
+
manifest.filestore !== 's3' &&
|
|
75
|
+
manifest.filestore !== 'blob'
|
|
76
|
+
) {
|
|
71
77
|
throw new ValidationError('The bundle manifest does not name a known file driver.')
|
|
72
78
|
}
|
|
73
79
|
|
|
@@ -378,12 +384,14 @@ async function stageLocalUploads(stage: string): Promise<'included' | 'skipped'>
|
|
|
378
384
|
return 'included'
|
|
379
385
|
}
|
|
380
386
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
export interface ListableStore {
|
|
388
|
+
listKeys(): AsyncGenerator<string>
|
|
389
|
+
get(key: string): Promise<Uint8Array | undefined>
|
|
390
|
+
}
|
|
385
391
|
|
|
392
|
+
export async function drainStoreToDirectory(store: ListableStore, dir: string): Promise<number> {
|
|
386
393
|
let pulled = 0
|
|
394
|
+
|
|
387
395
|
for await (const key of store.listKeys()) {
|
|
388
396
|
const target = path.resolve(dir, key)
|
|
389
397
|
if (target !== dir && !target.startsWith(dir + path.sep)) {
|
|
@@ -397,18 +405,66 @@ async function stageS3Uploads(stage: string): Promise<'included' | 'skipped'> {
|
|
|
397
405
|
pulled++
|
|
398
406
|
}
|
|
399
407
|
|
|
408
|
+
return pulled
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export async function uploadDirectoryToStore(
|
|
412
|
+
store: { put: FileStore['put'] },
|
|
413
|
+
dir: string,
|
|
414
|
+
): Promise<number> {
|
|
415
|
+
let pushed = 0
|
|
416
|
+
|
|
417
|
+
for (const file of await walk(dir)) {
|
|
418
|
+
const key = path.relative(dir, file).split(path.sep).join('/')
|
|
419
|
+
await store.put(key, await readFile(file), {
|
|
420
|
+
contentType: contentTypeFor(key),
|
|
421
|
+
visibility: 'public',
|
|
422
|
+
})
|
|
423
|
+
pushed++
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return pushed
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
async function stageObjectStoreUploads(
|
|
430
|
+
stage: string,
|
|
431
|
+
store: ListableStore,
|
|
432
|
+
origin: string,
|
|
433
|
+
): Promise<'included' | 'skipped'> {
|
|
434
|
+
const dir = path.join(stage, 'uploads')
|
|
435
|
+
await mkdir(dir, { recursive: true })
|
|
436
|
+
|
|
437
|
+
const pulled = await drainStoreToDirectory(store, dir)
|
|
438
|
+
|
|
400
439
|
if (pulled === 0) {
|
|
401
|
-
console.log(`
|
|
440
|
+
console.log(`Found no objects in ${origin}; the bundle carries no uploads.`)
|
|
402
441
|
await rm(dir, { recursive: true, force: true })
|
|
403
442
|
return 'skipped'
|
|
404
443
|
}
|
|
405
444
|
|
|
406
445
|
await run('tar', ['czf', path.join(stage, 'uploads.tar.gz'), '-C', dir, '.'])
|
|
407
446
|
await rm(dir, { recursive: true, force: true })
|
|
408
|
-
console.log(`Pulled ${pulled} object(s) from ${
|
|
447
|
+
console.log(`Pulled ${pulled} object(s) from ${origin}.`)
|
|
409
448
|
return 'included'
|
|
410
449
|
}
|
|
411
450
|
|
|
451
|
+
async function stageUploads(stage: string, mode: UploadsMode): Promise<'included' | 'skipped'> {
|
|
452
|
+
if (mode === 'skip') return 'skipped'
|
|
453
|
+
|
|
454
|
+
switch (env.FILESTORE_DRIVER) {
|
|
455
|
+
case 's3':
|
|
456
|
+
return await stageObjectStoreUploads(
|
|
457
|
+
stage,
|
|
458
|
+
S3FileStore.fromEnv(env),
|
|
459
|
+
`the ${env.S3_BUCKET} bucket`,
|
|
460
|
+
)
|
|
461
|
+
case 'blob':
|
|
462
|
+
return await stageObjectStoreUploads(stage, BlobFileStore.fromEnv(env), 'the Blob store')
|
|
463
|
+
case 'local':
|
|
464
|
+
return await stageLocalUploads(stage)
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
412
468
|
export async function backupCommand(args: readonly string[]): Promise<number> {
|
|
413
469
|
const { flags } = parseFlags(args)
|
|
414
470
|
requirePostgres()
|
|
@@ -434,12 +490,7 @@ export async function backupCommand(args: readonly string[]): Promise<number> {
|
|
|
434
490
|
databaseEnvironment,
|
|
435
491
|
)
|
|
436
492
|
|
|
437
|
-
const uploads =
|
|
438
|
-
mode === 'skip'
|
|
439
|
-
? 'skipped'
|
|
440
|
-
: env.FILESTORE_DRIVER === 's3'
|
|
441
|
-
? await stageS3Uploads(stage)
|
|
442
|
-
: await stageLocalUploads(stage)
|
|
493
|
+
const uploads = await stageUploads(stage, mode)
|
|
443
494
|
|
|
444
495
|
const manifest: BackupManifest = {
|
|
445
496
|
format: 1,
|
|
@@ -526,23 +577,19 @@ async function extractUploads(stage: string, dir: string, limits: RestoreLimits)
|
|
|
526
577
|
console.log(`Restored the uploads into ${dir}.`)
|
|
527
578
|
}
|
|
528
579
|
|
|
529
|
-
async function
|
|
580
|
+
async function pushUploadsToStore(
|
|
581
|
+
stage: string,
|
|
582
|
+
limits: RestoreLimits,
|
|
583
|
+
store: { put: FileStore['put'] },
|
|
584
|
+
destination: string,
|
|
585
|
+
): Promise<void> {
|
|
530
586
|
await validateUploadsArchive(stage, limits)
|
|
531
587
|
const dir = path.join(stage, 'uploads-extract')
|
|
532
588
|
await mkdir(dir, { recursive: true })
|
|
533
589
|
await run('tar', ['xzf', path.join(stage, 'uploads.tar.gz'), '-C', dir])
|
|
534
590
|
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
for (const file of await walk(dir)) {
|
|
538
|
-
const key = path.relative(dir, file).split(path.sep).join('/')
|
|
539
|
-
await store.put(key, await readFile(file), {
|
|
540
|
-
contentType: contentTypeFor(key),
|
|
541
|
-
visibility: 'public',
|
|
542
|
-
})
|
|
543
|
-
pushed++
|
|
544
|
-
}
|
|
545
|
-
console.log(`Uploaded ${pushed} object(s) to ${env.S3_BUCKET}.`)
|
|
591
|
+
const pushed = await uploadDirectoryToStore(store, dir)
|
|
592
|
+
console.log(`Uploaded ${pushed} object(s) to ${destination}.`)
|
|
546
593
|
}
|
|
547
594
|
|
|
548
595
|
const RESTORE_USAGE =
|
|
@@ -652,7 +699,9 @@ export async function restoreCommand(args: readonly string[]): Promise<number> {
|
|
|
652
699
|
if (manifest.uploads === 'included' && flags.get('skip-uploads') !== 'true') {
|
|
653
700
|
const uploadsDir = optional(flags, 'uploads-dir')
|
|
654
701
|
if (env.FILESTORE_DRIVER === 's3' && uploadsDir === undefined) {
|
|
655
|
-
await
|
|
702
|
+
await pushUploadsToStore(stage, limits, S3FileStore.fromEnv(env), `${env.S3_BUCKET}`)
|
|
703
|
+
} else if (env.FILESTORE_DRIVER === 'blob' && uploadsDir === undefined) {
|
|
704
|
+
await pushUploadsToStore(stage, limits, BlobFileStore.fromEnv(env), 'the Blob store')
|
|
656
705
|
} else {
|
|
657
706
|
await extractUploads(stage, uploadsDir ?? env.UPLOADS_DIR, limits)
|
|
658
707
|
}
|
|
@@ -662,7 +711,11 @@ export async function restoreCommand(args: readonly string[]): Promise<number> {
|
|
|
662
711
|
? `This bundle carries no uploads — they live in the S3 bucket${
|
|
663
712
|
manifest.bucket === undefined ? '' : ` (${manifest.bucket})`
|
|
664
713
|
}.`
|
|
665
|
-
:
|
|
714
|
+
: manifest.filestore === 'blob'
|
|
715
|
+
? 'This bundle carries no uploads, and a Vercel Blob store is not ' +
|
|
716
|
+
'something you can copy out by hand. Take another backup with ' +
|
|
717
|
+
'--uploads include while the old board still exists.'
|
|
718
|
+
: 'This bundle carries no uploads.',
|
|
666
719
|
)
|
|
667
720
|
}
|
|
668
721
|
|
package/src/board-eject.ts
CHANGED
|
@@ -17,8 +17,12 @@ import { CODE_VERSION } from './upgrade'
|
|
|
17
17
|
* bundled `dist/cli.cjs` does not sit at that same distance — Docker's own
|
|
18
18
|
* `COPY apps/cli/dist/ ./apps/cli/` drops the `dist` segment.
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
function defaultManifestPath(): string {
|
|
21
|
+
return join(
|
|
22
|
+
fileURLToPath(new URL('../../../', import.meta.url)),
|
|
23
|
+
'boards/stock/board.plugins.json',
|
|
24
|
+
)
|
|
25
|
+
}
|
|
22
26
|
|
|
23
27
|
interface ManifestEntry {
|
|
24
28
|
readonly key: string
|
|
@@ -31,7 +35,81 @@ interface Manifest {
|
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
function manifestPath(): string {
|
|
34
|
-
return process.env.BOARD_PLUGINS_MANIFEST ??
|
|
38
|
+
return process.env.BOARD_PLUGINS_MANIFEST ?? defaultManifestPath()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Duplicated from scripts/board-plugins.mjs's own PLUGIN_KEY_PATTERN, IDENTIFIER_PATTERN
|
|
43
|
+
* and NPM_PACKAGE_NAME_PATTERN rather than imported — see docs/plugin-api.md, "The board
|
|
44
|
+
* plugin manifests" — and pinned to agree with it by board-eject.test.ts.
|
|
45
|
+
*/
|
|
46
|
+
const PLUGIN_KEY_PATTERN = /^[a-z][a-z0-9-]{1,39}$/
|
|
47
|
+
const IDENTIFIER_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/
|
|
48
|
+
const NPM_PACKAGE_NAME_PATTERN = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The same shape of refusal scripts/board-plugins.mjs's validateManifest makes for
|
|
52
|
+
* apps/community and boards/stock, minus the dependency check — a deployed image
|
|
53
|
+
* carries no package.json listing what it was actually built with. A manifest that
|
|
54
|
+
* gets this far already passed that check once, when plugin:add wrote it; this is
|
|
55
|
+
* defense against a manifest hand-edited after the fact, not the primary gate.
|
|
56
|
+
*/
|
|
57
|
+
export function validateEjectManifest(plugins: readonly ManifestEntry[], path: string): void {
|
|
58
|
+
const seen = new Set<string>()
|
|
59
|
+
const identifiers = new Map<string, string>()
|
|
60
|
+
|
|
61
|
+
for (const entry of plugins) {
|
|
62
|
+
if (typeof entry.key !== 'string' || typeof entry.package !== 'string') {
|
|
63
|
+
throw new ValidationError(
|
|
64
|
+
`${path}: every entry needs a string "key" and "package". Got ${JSON.stringify(entry)}.`,
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (seen.has(entry.key)) {
|
|
69
|
+
throw new ValidationError(`${path}: "${entry.key}" is listed twice.`)
|
|
70
|
+
}
|
|
71
|
+
seen.add(entry.key)
|
|
72
|
+
|
|
73
|
+
if (!PLUGIN_KEY_PATTERN.test(entry.key)) {
|
|
74
|
+
throw new ValidationError(
|
|
75
|
+
`${path}: "${entry.key}" is not a valid plugin key. definePlugin requires lower-case ` +
|
|
76
|
+
'letters, digits and hyphens, starting with a letter, 2-40 characters long.',
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (entry.enabled !== undefined && typeof entry.enabled !== 'boolean') {
|
|
81
|
+
throw new ValidationError(
|
|
82
|
+
`${path}: "${entry.key}" has a non-boolean "enabled" (${JSON.stringify(entry.enabled)}). ` +
|
|
83
|
+
'Omit the field to enable the plugin, or set it to true or false.',
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!NPM_PACKAGE_NAME_PATTERN.test(entry.package) || entry.package.length > 214) {
|
|
88
|
+
throw new ValidationError(
|
|
89
|
+
`${path}: "${entry.package}" (key "${entry.key}") is not a valid npm package name.`,
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const identifier = toIdentifier(entry.key)
|
|
94
|
+
if (!IDENTIFIER_PATTERN.test(identifier)) {
|
|
95
|
+
throw new ValidationError(
|
|
96
|
+
`${path}: "${entry.key}" is a valid plugin key, but the identifier ` +
|
|
97
|
+
`community.plugins.ts would bind for it, "${identifier}", is not a valid TypeScript ` +
|
|
98
|
+
'identifier. Each hyphen must be followed by exactly one lower-case letter or digit, ' +
|
|
99
|
+
'and a key cannot end in a hyphen.',
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const collidingKey = identifiers.get(identifier)
|
|
104
|
+
if (collidingKey !== undefined) {
|
|
105
|
+
throw new ValidationError(
|
|
106
|
+
`${path}: "${entry.key}" and "${collidingKey}" both generate the identifier ` +
|
|
107
|
+
`"${identifier}" for community.plugins.ts. Rename one of the keys so the generated ` +
|
|
108
|
+
'imports do not collide.',
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
identifiers.set(identifier, entry.key)
|
|
112
|
+
}
|
|
35
113
|
}
|
|
36
114
|
|
|
37
115
|
/**
|
|
@@ -63,6 +141,7 @@ async function readManifest(): Promise<Manifest> {
|
|
|
63
141
|
if (!Array.isArray(parsed.plugins)) {
|
|
64
142
|
throw new ValidationError(`${path} must have a "plugins" array.`)
|
|
65
143
|
}
|
|
144
|
+
validateEjectManifest(parsed.plugins, path)
|
|
66
145
|
return { plugins: parsed.plugins }
|
|
67
146
|
}
|
|
68
147
|
|
|
@@ -75,10 +154,33 @@ async function isEmptyOrMissing(target: string): Promise<boolean> {
|
|
|
75
154
|
}
|
|
76
155
|
}
|
|
77
156
|
|
|
78
|
-
function toIdentifier(key: string): string {
|
|
157
|
+
export function toIdentifier(key: string): string {
|
|
79
158
|
return key.replace(/-([a-z0-9])/g, (_match, char) => char.toUpperCase())
|
|
80
159
|
}
|
|
81
160
|
|
|
161
|
+
interface EjectedPackageJson {
|
|
162
|
+
dependencies: Record<string, string>
|
|
163
|
+
[key: string]: unknown
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Every manifest entry's package pinned into the scaffolded package.json's
|
|
168
|
+
* dependencies, at this exact running version — see docs/marketplace.md,
|
|
169
|
+
* "1. Eject", for why never `latest`, and for the collision policy this
|
|
170
|
+
* implements: a package scaffold() already pins is left exactly where it
|
|
171
|
+
* is, never duplicated or reordered, because both pins are always this
|
|
172
|
+
* same CODE_VERSION.
|
|
173
|
+
*/
|
|
174
|
+
function mergePluginDependencies(packageJson: string, plugins: readonly ManifestEntry[]): string {
|
|
175
|
+
const parsed = JSON.parse(packageJson) as EjectedPackageJson
|
|
176
|
+
for (const entry of plugins) {
|
|
177
|
+
if (!(entry.package in parsed.dependencies)) {
|
|
178
|
+
parsed.dependencies[entry.package] = CODE_VERSION
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return `${JSON.stringify(parsed, null, 2)}\n`
|
|
182
|
+
}
|
|
183
|
+
|
|
82
184
|
/**
|
|
83
185
|
* The ejected workspace's own community.plugins.ts — the same shape
|
|
84
186
|
* create-meith's scaffold() writes for a plugin-free board (see
|
|
@@ -122,6 +224,30 @@ export function installedPluginDefinitions() {
|
|
|
122
224
|
`
|
|
123
225
|
}
|
|
124
226
|
|
|
227
|
+
function isFsPermissionError(error: unknown): error is NodeJS.ErrnoException {
|
|
228
|
+
const code = (error as NodeJS.ErrnoException | undefined)?.code
|
|
229
|
+
return code === 'EACCES' || code === 'EPERM'
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Turns an EACCES/EPERM from the write loop below into this instead of a
|
|
234
|
+
* bare Node stack trace — see docs/marketplace.md, "1. Eject", for the
|
|
235
|
+
* bind-mount ownership rule this message is naming. Anything else passes
|
|
236
|
+
* through unchanged.
|
|
237
|
+
*/
|
|
238
|
+
function translateWriteError(error: unknown, target: string, path: string): never {
|
|
239
|
+
if (isFsPermissionError(error)) {
|
|
240
|
+
throw new ValidationError(
|
|
241
|
+
`board:eject could not write to ${path}: permission denied. The account running this ` +
|
|
242
|
+
`command needs write access to ${target} — inside the official image that account is ` +
|
|
243
|
+
'a fixed, non-root user, so a bind-mounted target directory has to already be owned by ' +
|
|
244
|
+
'(or writable by) that same account before eject runs. See docs/marketplace.md, ' +
|
|
245
|
+
'"Moving to a custom board", for the exact invocation.',
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
throw error
|
|
249
|
+
}
|
|
250
|
+
|
|
125
251
|
export async function boardEject(args: readonly string[]): Promise<number> {
|
|
126
252
|
const positional = args.filter((arg) => !arg.startsWith('-'))
|
|
127
253
|
const [dir] = positional
|
|
@@ -150,13 +276,22 @@ export async function boardEject(args: readonly string[]): Promise<number> {
|
|
|
150
276
|
const files = new Map(
|
|
151
277
|
scaffold({ name, version: CODE_VERSION, repositoryUrl: DEFAULT_REPOSITORY_URL }),
|
|
152
278
|
)
|
|
279
|
+
const packageJson = files.get('package.json')
|
|
280
|
+
if (packageJson === undefined) {
|
|
281
|
+
throw new Error('scaffold() did not emit package.json')
|
|
282
|
+
}
|
|
283
|
+
files.set('package.json', mergePluginDependencies(packageJson, manifest.plugins))
|
|
153
284
|
files.set('board.plugins.json', `${JSON.stringify({ plugins: manifest.plugins }, null, 2)}\n`)
|
|
154
285
|
files.set('community.plugins.ts', renderInstalledPluginsModule(manifest.plugins))
|
|
155
286
|
|
|
156
287
|
for (const [relative, contents] of files) {
|
|
157
288
|
const path = join(target, relative)
|
|
158
|
-
|
|
159
|
-
|
|
289
|
+
try {
|
|
290
|
+
await mkdir(dirname(path), { recursive: true })
|
|
291
|
+
await writeFile(path, contents, 'utf8')
|
|
292
|
+
} catch (error) {
|
|
293
|
+
translateWriteError(error, target, path)
|
|
294
|
+
}
|
|
160
295
|
}
|
|
161
296
|
|
|
162
297
|
console.log(`Ejected ${files.size} files to ${target}, pinned to meith ${CODE_VERSION}.`)
|
package/src/index.ts
CHANGED
|
@@ -84,6 +84,19 @@ const commands: Command[] = [
|
|
|
84
84
|
{
|
|
85
85
|
name: 'migrate',
|
|
86
86
|
summary: 'Apply pending database migrations.',
|
|
87
|
+
usage: [
|
|
88
|
+
'community migrate',
|
|
89
|
+
'',
|
|
90
|
+
'Applies every migration this release has that the board has not, then exits.',
|
|
91
|
+
'Safe to run concurrently: the runner holds a Postgres advisory lock for the',
|
|
92
|
+
'whole run, so a second deploy waits for the first and then finds nothing to do.',
|
|
93
|
+
'',
|
|
94
|
+
'Migrates over DIRECT_DATABASE_URL when it is set, and over DATABASE_URL when it',
|
|
95
|
+
'is not. On a managed database point DIRECT_DATABASE_URL at the direct',
|
|
96
|
+
'(non-pooler) connection string: a transaction-mode pooler hands the connection',
|
|
97
|
+
'back as soon as the lock statement ends, so the lock is left on a backend that',
|
|
98
|
+
'goes to somebody else and the run is no longer serialised against other runs.',
|
|
99
|
+
].join('\n'),
|
|
87
100
|
async run() {
|
|
88
101
|
const { assertEnv } = await import('@meith/core')
|
|
89
102
|
const env = assertEnv()
|
|
@@ -93,6 +106,12 @@ const commands: Command[] = [
|
|
|
93
106
|
return 1
|
|
94
107
|
}
|
|
95
108
|
|
|
109
|
+
console.log(
|
|
110
|
+
env.DIRECT_DATABASE_URL === undefined
|
|
111
|
+
? 'Migrating over DATABASE_URL…'
|
|
112
|
+
: 'Migrating over DIRECT_DATABASE_URL…',
|
|
113
|
+
)
|
|
114
|
+
|
|
96
115
|
const { runMigrations } = await import('@meith/db')
|
|
97
116
|
const applied = await runMigrations()
|
|
98
117
|
console.log(applied === 0 ? 'Already up to date.' : `Applied ${applied} migration(s).`)
|
package/src/plugin-manifest.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
5
5
|
|
|
6
6
|
import { ValidationError } from '@meith/core'
|
|
7
7
|
|
|
8
|
+
import BOARDS_JSON from '../../../scripts/boards.json'
|
|
8
9
|
import { optional, parseFlags } from './args'
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -12,9 +13,33 @@ import { optional, parseFlags } from './args'
|
|
|
12
13
|
* distance from the repository root (apps/cli/{src,dist}/<file> either way), so this
|
|
13
14
|
* offset holds whether these commands run from source (tsx) or the built dist/cli.cjs.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
function repoRoot(): string {
|
|
17
|
+
return fileURLToPath(new URL('../../../', import.meta.url))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function generatorScript(): string {
|
|
21
|
+
return join(repoRoot(), 'scripts/board-plugins-gen.mjs')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Every board's board.plugins.json is edited together, from the one list in
|
|
26
|
+
* scripts/boards.json that scripts/board-plugins-gen.mjs reads too. That file
|
|
27
|
+
* and the MEITH_BOARD_PLUGINS_ROOT override are described in
|
|
28
|
+
* docs/development.md, "The board plugin manifests".
|
|
29
|
+
*/
|
|
30
|
+
interface Board {
|
|
31
|
+
readonly manifestFile: string
|
|
32
|
+
readonly packageFile: string
|
|
33
|
+
readonly outputFile: string
|
|
34
|
+
readonly packageLabel: string
|
|
35
|
+
readonly filterName: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const BOARDS = BOARDS_JSON as readonly Board[]
|
|
39
|
+
|
|
40
|
+
function boardsRoot(): string {
|
|
41
|
+
return process.env.MEITH_BOARD_PLUGINS_ROOT ?? repoRoot()
|
|
42
|
+
}
|
|
18
43
|
|
|
19
44
|
interface ManifestEntry {
|
|
20
45
|
readonly key: string
|
|
@@ -32,19 +57,21 @@ interface Manifest {
|
|
|
32
57
|
* one meant to run as `docker compose run --rm web community plugin:purge`. The deployed
|
|
33
58
|
* image is built `FROM node:26-alpine` with only `.next/standalone`, the worker and this
|
|
34
59
|
* CLI's own bundle copied in (see docker/Dockerfile) — no `scripts/`, no `board.plugins.json`,
|
|
35
|
-
* no Biome. Reading
|
|
60
|
+
* no Biome. Reading a manifest is where that shows up first, so this is where it is named.
|
|
36
61
|
*/
|
|
37
|
-
async function
|
|
62
|
+
async function readManifestFor(board: Board): Promise<Manifest> {
|
|
63
|
+
const path = join(boardsRoot(), board.manifestFile)
|
|
38
64
|
let raw: string
|
|
39
65
|
try {
|
|
40
|
-
raw = await readFile(
|
|
66
|
+
raw = await readFile(path, 'utf8')
|
|
41
67
|
} catch (error) {
|
|
42
68
|
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
43
69
|
throw new ValidationError(
|
|
44
|
-
`${
|
|
45
|
-
'
|
|
46
|
-
'it
|
|
47
|
-
'
|
|
70
|
+
`${path} does not exist. This command edits source files for every board this ` +
|
|
71
|
+
'repository carries — apps/community and boards/stock — and reruns the generator, ' +
|
|
72
|
+
'so it needs a checkout of the repository, not the deployed image — run it where you ' +
|
|
73
|
+
'would run `pnpm add`, commit both board.plugins.json files and both ' +
|
|
74
|
+
'community.plugins.ts files, then rebuild and redeploy.',
|
|
48
75
|
)
|
|
49
76
|
}
|
|
50
77
|
throw error
|
|
@@ -52,13 +79,25 @@ async function readManifest(): Promise<Manifest> {
|
|
|
52
79
|
|
|
53
80
|
const parsed = JSON.parse(raw) as Partial<Manifest>
|
|
54
81
|
if (!Array.isArray(parsed.plugins)) {
|
|
55
|
-
throw new ValidationError(
|
|
82
|
+
throw new ValidationError(`${path} must have a "plugins" array.`)
|
|
56
83
|
}
|
|
84
|
+
|
|
85
|
+
const extraFields = Object.keys(parsed).filter((field) => field !== 'plugins')
|
|
86
|
+
if (extraFields.length > 0) {
|
|
87
|
+
throw new ValidationError(
|
|
88
|
+
`${path} has ${extraFields.length === 1 ? 'a field' : 'fields'} plugin:add/plugin:remove ` +
|
|
89
|
+
`do not know how to carry forward: ${extraFields.join(', ')}. "plugins" is the ` +
|
|
90
|
+
"manifest's only field — remove the rest by hand, since rewriting the file here would " +
|
|
91
|
+
'otherwise drop them silently.',
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
57
95
|
return { plugins: parsed.plugins }
|
|
58
96
|
}
|
|
59
97
|
|
|
60
|
-
async function
|
|
61
|
-
|
|
98
|
+
async function writeManifestFor(board: Board, manifest: Manifest): Promise<void> {
|
|
99
|
+
const path = join(boardsRoot(), board.manifestFile)
|
|
100
|
+
await writeFile(path, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8')
|
|
62
101
|
}
|
|
63
102
|
|
|
64
103
|
interface GeneratorResult {
|
|
@@ -68,14 +107,15 @@ interface GeneratorResult {
|
|
|
68
107
|
|
|
69
108
|
/**
|
|
70
109
|
* The one thing this file trusts to know whether a manifest edit is valid: the same
|
|
71
|
-
* generator `pnpm board:gen` runs. Shelling out — rather
|
|
72
|
-
* scripts/board-plugins.mjs — keeps a plain script and a workspace
|
|
73
|
-
* from needing to share a module; it also means a failed add or
|
|
74
|
-
* exactly the words a person typing `pnpm board:gen` themselves
|
|
110
|
+
* generator `pnpm board:gen` runs, for every board it carries. Shelling out — rather
|
|
111
|
+
* than importing scripts/board-plugins.mjs — keeps a plain script and a workspace
|
|
112
|
+
* TypeScript package from needing to share a module; it also means a failed add or
|
|
113
|
+
* remove is reported in exactly the words a person typing `pnpm board:gen` themselves
|
|
114
|
+
* would see, board by board.
|
|
75
115
|
*/
|
|
76
116
|
function runGenerator(): GeneratorResult {
|
|
77
117
|
try {
|
|
78
|
-
const output = execFileSync(process.execPath, [
|
|
118
|
+
const output = execFileSync(process.execPath, [generatorScript()], {
|
|
79
119
|
encoding: 'utf8',
|
|
80
120
|
stdio: 'pipe',
|
|
81
121
|
})
|
|
@@ -109,7 +149,7 @@ export async function pluginAdd(args: readonly string[]): Promise<number> {
|
|
|
109
149
|
throw new ValidationError(
|
|
110
150
|
`community plugin:add does not take plugin configuration (--${configFlags[0]}). The ` +
|
|
111
151
|
"manifest has no field for it — a plugin's own settings are the only place its " +
|
|
112
|
-
|
|
152
|
+
"configuration lives now, the way MEI-74 moved plugins/dues's plans there. Export a " +
|
|
113
153
|
'zero-argument plugin and add it with just its package name.',
|
|
114
154
|
)
|
|
115
155
|
}
|
|
@@ -122,23 +162,35 @@ export async function pluginAdd(args: readonly string[]): Promise<number> {
|
|
|
122
162
|
)
|
|
123
163
|
}
|
|
124
164
|
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
165
|
+
const originals = await Promise.all(BOARDS.map((board) => readManifestFor(board)))
|
|
166
|
+
|
|
167
|
+
originals.forEach(({ plugins }, index) => {
|
|
168
|
+
if (plugins.some((entry) => entry.key === key)) {
|
|
169
|
+
throw new ValidationError(`"${key}" is already in ${BOARDS[index]?.manifestFile}.`)
|
|
170
|
+
}
|
|
171
|
+
})
|
|
129
172
|
|
|
130
173
|
const entry: ManifestEntry = { key, package: packageName, enabled: !flags.has('disabled') }
|
|
131
|
-
|
|
174
|
+
|
|
175
|
+
await Promise.all(
|
|
176
|
+
BOARDS.map((board, index) =>
|
|
177
|
+
writeManifestFor(board, { plugins: [...(originals[index]?.plugins ?? []), entry] }),
|
|
178
|
+
),
|
|
179
|
+
)
|
|
132
180
|
|
|
133
181
|
const result = runGenerator()
|
|
134
182
|
if (!result.ok) {
|
|
135
|
-
await
|
|
183
|
+
await Promise.all(
|
|
184
|
+
BOARDS.map((board, index) => writeManifestFor(board, originals[index] ?? { plugins: [] })),
|
|
185
|
+
)
|
|
136
186
|
throw new ValidationError(`Could not add "${key}":\n\n${result.output}`)
|
|
137
187
|
}
|
|
138
188
|
|
|
189
|
+
const manifestFiles = BOARDS.map((board) => board.manifestFile).join(' and ')
|
|
190
|
+
const outputFiles = BOARDS.map((board) => board.outputFile).join(' and ')
|
|
139
191
|
console.log(
|
|
140
|
-
`Added "${key}" (${packageName}${entry.enabled ? '' : ', disabled'}) to
|
|
141
|
-
|
|
192
|
+
`Added "${key}" (${packageName}${entry.enabled ? '' : ', disabled'}) to ${manifestFiles} ` +
|
|
193
|
+
`and regenerated ${outputFiles}.`,
|
|
142
194
|
)
|
|
143
195
|
console.log('Rebuild and redeploy for it to take effect.')
|
|
144
196
|
return 0
|
|
@@ -152,25 +204,38 @@ export async function pluginRemove(args: readonly string[]): Promise<number> {
|
|
|
152
204
|
throw new ValidationError('Usage: community plugin:remove <key>')
|
|
153
205
|
}
|
|
154
206
|
|
|
155
|
-
const
|
|
156
|
-
if (!manifest.plugins.some((entry) => entry.key === key)) {
|
|
157
|
-
const present = manifest.plugins.map((entry) => entry.key)
|
|
158
|
-
throw new ValidationError(
|
|
159
|
-
present.length === 0
|
|
160
|
-
? `"${key}" is not in board.plugins.json — it lists no plugins.`
|
|
161
|
-
: `"${key}" is not in board.plugins.json. Present: ${present.join(', ')}.`,
|
|
162
|
-
)
|
|
163
|
-
}
|
|
207
|
+
const originals = await Promise.all(BOARDS.map((board) => readManifestFor(board)))
|
|
164
208
|
|
|
165
|
-
|
|
209
|
+
originals.forEach(({ plugins }, index) => {
|
|
210
|
+
if (!plugins.some((entry) => entry.key === key)) {
|
|
211
|
+
const present = plugins.map((entry) => entry.key)
|
|
212
|
+
throw new ValidationError(
|
|
213
|
+
present.length === 0
|
|
214
|
+
? `"${key}" is not in ${BOARDS[index]?.manifestFile} — it lists no plugins.`
|
|
215
|
+
: `"${key}" is not in ${BOARDS[index]?.manifestFile}. Present: ${present.join(', ')}.`,
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
await Promise.all(
|
|
221
|
+
BOARDS.map((board, index) =>
|
|
222
|
+
writeManifestFor(board, {
|
|
223
|
+
plugins: (originals[index]?.plugins ?? []).filter((entry) => entry.key !== key),
|
|
224
|
+
}),
|
|
225
|
+
),
|
|
226
|
+
)
|
|
166
227
|
|
|
167
228
|
const result = runGenerator()
|
|
168
229
|
if (!result.ok) {
|
|
169
|
-
await
|
|
230
|
+
await Promise.all(
|
|
231
|
+
BOARDS.map((board, index) => writeManifestFor(board, originals[index] ?? { plugins: [] })),
|
|
232
|
+
)
|
|
170
233
|
throw new ValidationError(`Could not remove "${key}":\n\n${result.output}`)
|
|
171
234
|
}
|
|
172
235
|
|
|
173
|
-
|
|
236
|
+
const manifestFiles = BOARDS.map((board) => board.manifestFile).join(' and ')
|
|
237
|
+
const outputFiles = BOARDS.map((board) => board.outputFile).join(' and ')
|
|
238
|
+
console.log(`Removed "${key}" from ${manifestFiles} and regenerated ${outputFiles}.`)
|
|
174
239
|
console.log('Rebuild and redeploy for it to take effect.')
|
|
175
240
|
return 0
|
|
176
241
|
}
|
package/src/redaction.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
export const SECRET_ENV_KEYS: ReadonlySet<string> = new Set([
|
|
2
2
|
'AUTH_SECRET',
|
|
3
3
|
'TICK_SECRET',
|
|
4
|
+
'CRON_SECRET',
|
|
4
5
|
'METRICS_TOKEN',
|
|
5
6
|
'DATABASE_URL',
|
|
6
7
|
'DIRECT_DATABASE_URL',
|
|
7
8
|
'MAIL_HTTP_TOKEN',
|
|
8
9
|
'MAIL_SMTP_PASSWORD',
|
|
10
|
+
'RESEND_API_KEY',
|
|
9
11
|
'REDIS_URL',
|
|
10
12
|
'S3_SECRET_ACCESS_KEY',
|
|
13
|
+
'BLOB_READ_WRITE_TOKEN',
|
|
11
14
|
])
|
|
12
15
|
|
|
13
16
|
export const NOT_SECRET_DESPITE_THE_NAME: ReadonlySet<string> = new Set([
|
|
14
17
|
'MAIL_HTTP_ENDPOINT',
|
|
15
18
|
'S3_ENDPOINT',
|
|
19
|
+
'S3_PUBLIC_BASE_URL',
|
|
16
20
|
'APP_URL',
|
|
17
21
|
'S3_ACCESS_KEY_ID',
|
|
18
22
|
'MAIL_SMTP_USERNAME',
|
package/src/upgrade.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { type PluginDefinition, pluginNavigationPlacements } from '@meith/plugin
|
|
|
11
11
|
import { runPluginLifecycle } from '@meith/runtime'
|
|
12
12
|
import { type PluginUpgrade, planUpgrade, upgradeNotice } from '@meith/upgrade'
|
|
13
13
|
|
|
14
|
-
export const CODE_VERSION = '0.
|
|
14
|
+
export const CODE_VERSION = '0.18.0'
|
|
15
15
|
|
|
16
16
|
export function pluginUpgrades(plugins: readonly PluginDefinition[]): readonly PluginUpgrade[] {
|
|
17
17
|
return plugins.map((plugin) => ({
|