@prenta/cli 0.17.2 β 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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +28 -28
- package/CHANGELOG.md +6 -0
- package/dist/commands/migrate-content-hash.d.ts +3 -0
- package/dist/commands/migrate-content-hash.d.ts.map +1 -0
- package/dist/commands/migrate-content-hash.js +90 -0
- package/dist/commands/migrate-content-hash.js.map +1 -0
- package/dist/commands/migrate-media-optimize.d.ts.map +1 -1
- package/dist/commands/migrate-media-optimize.js +1 -30
- package/dist/commands/migrate-media-optimize.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/load-project-config.d.ts +7 -0
- package/dist/utils/load-project-config.d.ts.map +1 -0
- package/dist/utils/load-project-config.js +37 -0
- package/dist/utils/load-project-config.js.map +1 -0
- package/package.json +2 -2
- package/src/commands/migrate-content-hash.ts +108 -0
- package/src/commands/migrate-media-optimize.ts +1 -38
- package/src/index.ts +2 -0
- package/src/utils/load-project-config.ts +44 -0
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
|
|
2
|
-
> @prenta/cli@0.
|
|
2
|
+
> @prenta/cli@0.18.0 test /home/runner/work/prenta/prenta/packages/cli
|
|
3
3
|
> vitest run "--no-file-parallelism"
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.8 [39m[90m/home/runner/work/prenta/prenta/packages/cli[39m
|
|
7
7
|
|
|
8
|
-
[32mβ[39m src/__tests__/db-restore.test.ts [2m([22m[2m34 tests[22m[2m)[22m[33m
|
|
9
|
-
[32mβ[39m src/__tests__/db-backup.test.ts [2m([22m[2m27 tests[22m[2m)[22m[33m
|
|
10
|
-
[32mβ[39m src/__tests__/deployment-diagnostics.test.ts [2m([22m[2m23 tests[22m[2m)[22m[32m
|
|
11
|
-
[32mβ[39m src/__tests__/backup-blob-store.test.ts [2m([22m[2m18 tests[22m[2m)[22m[
|
|
12
|
-
[32mβ[39m src/__tests__/backup-pg-tools.test.ts [2m([22m[2m26 tests[22m[2m)[22m[32m
|
|
13
|
-
[32mβ[39m src/__tests__/db-sync.test.ts [2m([22m[2m13 tests[22m[2m)[22m[32m
|
|
8
|
+
[32mβ[39m src/__tests__/db-restore.test.ts [2m([22m[2m34 tests[22m[2m)[22m[33m 1273[2mms[22m[39m
|
|
9
|
+
[32mβ[39m src/__tests__/db-backup.test.ts [2m([22m[2m27 tests[22m[2m)[22m[33m 760[2mms[22m[39m
|
|
10
|
+
[32mβ[39m src/__tests__/deployment-diagnostics.test.ts [2m([22m[2m23 tests[22m[2m)[22m[32m 45[2mms[22m[39m
|
|
11
|
+
[32mβ[39m src/__tests__/backup-blob-store.test.ts [2m([22m[2m18 tests[22m[2m)[22m[32m 294[2mms[22m[39m
|
|
12
|
+
[32mβ[39m src/__tests__/backup-pg-tools.test.ts [2m([22m[2m26 tests[22m[2m)[22m[32m 25[2mms[22m[39m
|
|
13
|
+
[32mβ[39m src/__tests__/db-sync.test.ts [2m([22m[2m13 tests[22m[2m)[22m[32m 221[2mms[22m[39m
|
|
14
14
|
[2m[90mβ[39m[22m src/__tests__/integration/backup-roundtrip.int.test.ts [2m([22m[2m1 test[22m[2m | [22m[33m1 skipped[39m[2m)[22m
|
|
15
|
-
[32mβ[39m src/__tests__/backup-manifest.test.ts [2m([22m[2m17 tests[22m[2m)[22m[32m
|
|
16
|
-
[32mβ[39m src/__tests__/backup-crypto.test.ts [2m([22m[2m13 tests[22m[2m)[22m[32m
|
|
17
|
-
[32mβ[39m src/__tests__/seed.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m
|
|
18
|
-
[32mβ[39m src/__tests__/backup-common.test.ts [2m([22m[2m14 tests[22m[2m)[22m[32m
|
|
15
|
+
[32mβ[39m src/__tests__/backup-manifest.test.ts [2m([22m[2m17 tests[22m[2m)[22m[32m 66[2mms[22m[39m
|
|
16
|
+
[32mβ[39m src/__tests__/backup-crypto.test.ts [2m([22m[2m13 tests[22m[2m)[22m[32m 150[2mms[22m[39m
|
|
17
|
+
[32mβ[39m src/__tests__/seed.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 99[2mms[22m[39m
|
|
18
|
+
[32mβ[39m src/__tests__/backup-common.test.ts [2m([22m[2m14 tests[22m[2m)[22m[32m 20[2mms[22m[39m
|
|
19
19
|
- Reading canonical Prenta schema...
|
|
20
20
|
β Prenta CMS models added to schema.
|
|
21
21
|
- Running prisma generate...
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
[22m[39mβ Prisma client generated.
|
|
24
24
|
βΉ Run `npx prisma migrate dev --name prenta-cms` to create the migration.
|
|
25
25
|
|
|
26
|
+
- Reading canonical Prenta schema...
|
|
27
|
+
β Could not locate @prenta/core.
|
|
26
28
|
[90mstdout[2m | src/__tests__/db-init.test.ts[2m > [22m[2mdb:init (WS-D D5 β canonical schema, no stale fragment)[2m > [22m[2mcommand[2m > [22m[2mfails clearly when cms-core cannot be located
|
|
27
29
|
[22m[39mβΉ Install it first: `npm install @prenta/core`.
|
|
28
|
-
- Reading canonical Prenta schema...
|
|
29
30
|
|
|
30
|
-
β Could not locate @prenta/core.
|
|
31
31
|
- Reading canonical Prenta schema...
|
|
32
|
+
β Prenta CMS models added to schema.
|
|
32
33
|
[90mstdout[2m | src/__tests__/db-init.test.ts[2m > [22m[2mdb:init (WS-D D5 β canonical schema, no stale fragment)[2m > [22m[2mcommand[2m > [22m[2mis idempotent without --force
|
|
33
34
|
[22m[39mβ Prisma client generated.
|
|
34
35
|
βΉ Run `npx prisma migrate dev --name prenta-cms` to create the migration.
|
|
35
|
-
|
|
36
|
-
β Prenta CMS models added to schema.
|
|
37
36
|
- Running prisma generate...
|
|
37
|
+
|
|
38
38
|
- Reading canonical Prenta schema...
|
|
39
39
|
βΉ Prenta CMS models already present in schema. Use --force to overwrite.
|
|
40
40
|
[32mβ[39m src/__tests__/db-init.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 93[2mms[22m[39m
|
|
@@ -166,13 +166,13 @@ Next steps
|
|
|
166
166
|
3. Restart Cursor / VS Code so the MCP server is picked up
|
|
167
167
|
Tip: pass --url https://your-site.com to target a deployed CMS instead.
|
|
168
168
|
|
|
169
|
-
[32mβ[39m src/__tests__/mcp-init.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m
|
|
170
|
-
[32mβ[39m src/__tests__/prisma-client-path.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m
|
|
171
|
-
[32mβ[39m src/__tests__/form-seed.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m
|
|
172
|
-
[32mβ[39m src/__tests__/vercel-env-matrix.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m
|
|
173
|
-
[32mβ[39m src/__tests__/upgrade.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m
|
|
174
|
-
[32mβ[39m src/__tests__/repo-root.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m
|
|
175
|
-
[32mβ[39m src/__tests__/load-dotenv.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m
|
|
169
|
+
[32mβ[39m src/__tests__/mcp-init.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 124[2mms[22m[39m
|
|
170
|
+
[32mβ[39m src/__tests__/prisma-client-path.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 37[2mms[22m[39m
|
|
171
|
+
[32mβ[39m src/__tests__/form-seed.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 17[2mms[22m[39m
|
|
172
|
+
[32mβ[39m src/__tests__/vercel-env-matrix.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 17[2mms[22m[39m
|
|
173
|
+
[32mβ[39m src/__tests__/upgrade.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
174
|
+
[32mβ[39m src/__tests__/repo-root.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 16[2mms[22m[39m
|
|
175
|
+
[32mβ[39m src/__tests__/load-dotenv.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 31[2mms[22m[39m
|
|
176
176
|
- Reading canonical Prenta schema...
|
|
177
177
|
β Prenta CMS models added to schema.
|
|
178
178
|
- Running prisma generate...
|
|
@@ -180,13 +180,13 @@ Next steps
|
|
|
180
180
|
[22m[39mβ Prisma client generated.
|
|
181
181
|
βΉ Run `npx prisma migrate dev --name prenta-cms` to create the migration.
|
|
182
182
|
|
|
183
|
-
[32mβ[39m src/__tests__/schema-fragment.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m
|
|
184
|
-
[32mβ[39m src/__tests__/db-sync-resolver.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m
|
|
185
|
-
[32mβ[39m src/__tests__/import-typescript.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m
|
|
186
|
-
[32mβ[39m src/__tests__/init.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m
|
|
183
|
+
[32mβ[39m src/__tests__/schema-fragment.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 60[2mms[22m[39m
|
|
184
|
+
[32mβ[39m src/__tests__/db-sync-resolver.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
185
|
+
[32mβ[39m src/__tests__/import-typescript.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 123[2mms[22m[39m
|
|
186
|
+
[32mβ[39m src/__tests__/init.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 16[2mms[22m[39m
|
|
187
187
|
|
|
188
188
|
[2m Test Files [22m [1m[32m22 passed[39m[22m[2m | [22m[33m1 skipped[39m[90m (23)[39m
|
|
189
189
|
[2m Tests [22m [1m[32m249 passed[39m[22m[2m | [22m[33m1 skipped[39m[90m (250)[39m
|
|
190
|
-
[2m Start at [22m
|
|
191
|
-
[2m Duration [22m
|
|
190
|
+
[2m Start at [22m 03:46:37
|
|
191
|
+
[2m Duration [22m 15.75s[2m (transform 2.30s, setup 0ms, import 4.27s, tests 3.50s, environment 16ms)[22m
|
|
192
192
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @actuate-media/cli
|
|
2
2
|
|
|
3
|
+
## 0.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- eadf991: Add `prenta migrate:content-hash` to fill NULL `Media.contentHash` values from stored bytes so upload dedupe matches libraries that predate the column. Colliding byte-identical rows are reported and left in place.
|
|
8
|
+
|
|
3
9
|
## 0.17.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-content-hash.d.ts","sourceRoot":"","sources":["../../src/commands/migrate-content-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAgGnC,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAWxE"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import ora from 'ora';
|
|
2
|
+
import { connectProjectDatabase } from '../utils/database.js';
|
|
3
|
+
import { loadProjectConfig } from '../utils/load-project-config.js';
|
|
4
|
+
import { loadProjectEnv } from '../utils/load-dotenv.js';
|
|
5
|
+
import { logger } from '../utils/logger.js';
|
|
6
|
+
function parsePositiveInt(raw, flag) {
|
|
7
|
+
if (raw === undefined)
|
|
8
|
+
return undefined;
|
|
9
|
+
const value = Number.parseInt(raw, 10);
|
|
10
|
+
if (!Number.isFinite(value) || value <= 0 || String(value) !== raw.trim()) {
|
|
11
|
+
logger.error(`${flag} must be a positive integer.`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
/** `prenta migrate:content-hash` β fill Media.contentHash so upload dedupe can match legacy files. */
|
|
17
|
+
async function runMigrateContentHash(options) {
|
|
18
|
+
const dryRun = options.dryRun ?? false;
|
|
19
|
+
const limit = parsePositiveInt(options.limit, '--limit');
|
|
20
|
+
const batchSize = parsePositiveInt(options.batchSize, '--batch-size');
|
|
21
|
+
await loadProjectEnv(process.cwd()).then((env) => {
|
|
22
|
+
for (const [key, value] of Object.entries(env)) {
|
|
23
|
+
if (value !== undefined && process.env[key] === undefined) {
|
|
24
|
+
process.env[key] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
await loadProjectConfig(options.config ?? 'prenta.config.ts');
|
|
29
|
+
let connection = null;
|
|
30
|
+
const spinner = ora(dryRun ? 'Hashing media library (dry run)β¦' : 'Backfilling media content hashesβ¦').start();
|
|
31
|
+
try {
|
|
32
|
+
connection = await connectProjectDatabase();
|
|
33
|
+
const { backfillMediaContentHash } = await import('@prenta/core');
|
|
34
|
+
const result = await backfillMediaContentHash(connection.db, {
|
|
35
|
+
dryRun,
|
|
36
|
+
limit,
|
|
37
|
+
batchSize,
|
|
38
|
+
});
|
|
39
|
+
spinner.succeed(dryRun
|
|
40
|
+
? `Dry run complete β ${result.hashed} asset(s) would be hashed.`
|
|
41
|
+
: `Hashed ${result.hashed} asset(s).`);
|
|
42
|
+
logger.info(` Scanned: ${result.scanned}`);
|
|
43
|
+
logger.info(` Hashed: ${result.hashed}`);
|
|
44
|
+
logger.info(` Failed: ${result.failed}`);
|
|
45
|
+
logger.info(` Remaining: ${result.remaining}`);
|
|
46
|
+
logger.info(` Collisions: ${result.collisions.length}`);
|
|
47
|
+
if (result.collisions.length > 0) {
|
|
48
|
+
logger.info('');
|
|
49
|
+
logger.info('Byte-identical groups (not merged β resolve these by hand):');
|
|
50
|
+
for (const group of result.collisions.slice(0, 20)) {
|
|
51
|
+
logger.info(` ${group.mediaIds.join(', ')}`);
|
|
52
|
+
}
|
|
53
|
+
if (result.collisions.length > 20) {
|
|
54
|
+
logger.info(` β¦and ${result.collisions.length - 20} more`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (result.errors.length > 0) {
|
|
58
|
+
logger.info('');
|
|
59
|
+
for (const err of result.errors.slice(0, 10)) {
|
|
60
|
+
logger.info(` ${err.id}: ${err.message}`);
|
|
61
|
+
}
|
|
62
|
+
if (result.errors.length > 10) {
|
|
63
|
+
logger.info(` β¦and ${result.errors.length - 10} more`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (result.remaining > 0 && !dryRun) {
|
|
67
|
+
logger.info('');
|
|
68
|
+
logger.info('Re-run to continue. Rows that already have a hash are skipped.');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
73
|
+
spinner.fail(`Content hash backfill failed: ${message}`);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
await connection?.disconnect();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function registerMigrateContentHashCommand(program) {
|
|
81
|
+
program
|
|
82
|
+
.command('migrate:content-hash')
|
|
83
|
+
.description('SHA-256 stored bytes onto media rows with a NULL contentHash so upload dedupe can match them. Idempotent. Reports collisions; does not merge or delete.')
|
|
84
|
+
.option('--dry-run', 'Download and report without writing hashes')
|
|
85
|
+
.option('--limit <n>', 'Max assets to download this run')
|
|
86
|
+
.option('--batch-size <n>', 'Media rows per DB page (default 50)')
|
|
87
|
+
.option('--config <path>', 'Path to prenta.config.ts (default: ./prenta.config.ts)')
|
|
88
|
+
.action(runMigrateContentHash);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=migrate-content-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-content-hash.js","sourceRoot":"","sources":["../../src/commands/migrate-content-hash.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,sBA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,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAChE,OAAO,CAAC,IAAI,CAAC,iCAAiC,OAAO,EAAE,CAAC,CAAA;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;YAAS,CAAC;QACT,MAAM,UAAU,EAAE,UAAU,EAAE,CAAA;IAChC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,OAAgB;IAChE,OAAO;SACJ,OAAO,CAAC,sBAAsB,CAAC;SAC/B,WAAW,CACV,yJAAyJ,CAC1J;SACA,MAAM,CAAC,WAAW,EAAE,4CAA4C,CAAC;SACjE,MAAM,CAAC,aAAa,EAAE,iCAAiC,CAAC;SACxD,MAAM,CAAC,kBAAkB,EAAE,qCAAqC,CAAC;SACjE,MAAM,CAAC,iBAAiB,EAAE,wDAAwD,CAAC;SACnF,MAAM,CAAC,qBAAqB,CAAC,CAAA;AAClC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-media-optimize.d.ts","sourceRoot":"","sources":["../../src/commands/migrate-media-optimize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"migrate-media-optimize.d.ts","sourceRoot":"","sources":["../../src/commands/migrate-media-optimize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA0FnC,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAY1E"}
|
|
@@ -1,37 +1,8 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
1
|
import ora from 'ora';
|
|
3
2
|
import { connectProjectDatabase } from '../utils/database.js';
|
|
4
|
-
import {
|
|
3
|
+
import { loadProjectConfig } from '../utils/load-project-config.js';
|
|
5
4
|
import { loadProjectEnv } from '../utils/load-dotenv.js';
|
|
6
5
|
import { logger } from '../utils/logger.js';
|
|
7
|
-
async function loadProjectConfig(configPath) {
|
|
8
|
-
try {
|
|
9
|
-
const { setPrentaConfig, setStorageAdapter, autoWireStorageAdapter } = await import('@prenta/core');
|
|
10
|
-
const mod = (await importProjectTypescript(resolve(configPath)));
|
|
11
|
-
const config = mod.default ?? mod.config;
|
|
12
|
-
if (!config || typeof config !== 'object')
|
|
13
|
-
return;
|
|
14
|
-
setPrentaConfig(config);
|
|
15
|
-
const platformStorage = config.platform?.storage;
|
|
16
|
-
if (platformStorage &&
|
|
17
|
-
typeof platformStorage === 'object' &&
|
|
18
|
-
typeof platformStorage.upload === 'function') {
|
|
19
|
-
setStorageAdapter(platformStorage);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const provider = platformStorage &&
|
|
23
|
-
typeof platformStorage === 'object' &&
|
|
24
|
-
typeof platformStorage.provider === 'string'
|
|
25
|
-
? platformStorage.provider
|
|
26
|
-
: undefined;
|
|
27
|
-
if (provider)
|
|
28
|
-
await autoWireStorageAdapter(provider);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
logger.warn(`Could not load ${configPath} β will fetch public media URLs directly. ` +
|
|
32
|
-
'Pass --config if uploads go through a private storage adapter.');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
6
|
/** `prenta migrate:media-optimize` β re-run WebP/dimension pipeline on existing media. */
|
|
36
7
|
async function runMigrateMediaOptimize(options) {
|
|
37
8
|
const dryRun = options.dryRun ?? false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-media-optimize.js","sourceRoot":"","sources":["../../src/commands/migrate-media-optimize.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"migrate-media-optimize.js","sourceRoot":"","sources":["../../src/commands/migrate-media-optimize.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,KAAK,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0C,CAAC;SAC/D,MAAM,CAAC,cAAc,EAAE,qDAAqD,CAAC;SAC7E,MAAM,CAAC,2BAA2B,EAAE,8CAA8C,CAAC;SACnF,MAAM,CAAC,kBAAkB,EAAE,qCAAqC,CAAC;SACjE,MAAM,CAAC,iBAAiB,EAAE,wDAAwD,CAAC;SACnF,MAAM,CAAC,uBAAuB,CAAC,CAAA;AACpC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { registerMigrateSchemaCommand } from './commands/migrate-schema.js';
|
|
|
6
6
|
import { registerMigrateMetaCommand } from './commands/migrate-meta.js';
|
|
7
7
|
import { registerMigrateMediaUsageCommand } from './commands/migrate-media-usage.js';
|
|
8
8
|
import { registerMigrateMediaOptimizeCommand } from './commands/migrate-media-optimize.js';
|
|
9
|
+
import { registerMigrateContentHashCommand } from './commands/migrate-content-hash.js';
|
|
9
10
|
import { registerGenerateCommand } from './commands/generate.js';
|
|
10
11
|
import { registerSeedCommand } from './commands/seed.js';
|
|
11
12
|
import { registerImportCommand } from './commands/import.js';
|
|
@@ -32,6 +33,7 @@ registerMigrateSchemaCommand(program);
|
|
|
32
33
|
registerMigrateMetaCommand(program);
|
|
33
34
|
registerMigrateMediaUsageCommand(program);
|
|
34
35
|
registerMigrateMediaOptimizeCommand(program);
|
|
36
|
+
registerMigrateContentHashCommand(program);
|
|
35
37
|
registerGenerateCommand(program);
|
|
36
38
|
registerSeedCommand(program);
|
|
37
39
|
registerImportCommand(program);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B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CAAA;AACrC,0BAA0B,CAAC,OAAO,CAAC,CAAA;AACnC,gCAAgC,CAAC,OAAO,CAAC,CAAA;AACzC,mCAAmC,CAAC,OAAO,CAAC,CAAA;AAC5C,iCAAiC,CAAC,OAAO,CAAC,CAAA;AAC1C,uBAAuB,CAAC,OAAO,CAAC,CAAA;AAChC,mBAAmB,CAAC,OAAO,CAAC,CAAA;AAC5B,qBAAqB,CAAC,OAAO,CAAC,CAAA;AAC9B,qBAAqB,CAAC,OAAO,CAAC,CAAA;AAC9B,sBAAsB,CAAC,OAAO,CAAC,CAAA;AAC/B,0BAA0B,CAAC,OAAO,CAAC,CAAA;AACnC,qBAAqB,CAAC,OAAO,CAAC,CAAA;AAC9B,qBAAqB,CAAC,OAAO,CAAC,CAAA;AAC9B,uBAAuB,CAAC,OAAO,CAAC,CAAA;AAChC,uBAAuB,CAAC,OAAO,CAAC,CAAA;AAChC,wBAAwB,CAAC,OAAO,CAAC,CAAA;AACjC,mBAAmB,CAAC,OAAO,CAAC,CAAA;AAC5B,qBAAqB,CAAC,OAAO,CAAC,CAAA;AAC9B,0BAA0B,CAAC,OAAO,CAAC,CAAA;AACnC,qBAAqB,CAAC,OAAO,CAAC,CAAA;AAC9B,6BAA6B,CAAC,OAAO,CAAC,CAAA;AACtC,kBAAkB,CAAC,OAAO,CAAC,CAAA;AAE3B,OAAO,CAAC,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load `prenta.config.ts` and register its storage adapter so media commands
|
|
3
|
+
* can download private blobs. A missing or unloadable config falls through
|
|
4
|
+
* to a public-URL fetch.
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadProjectConfig(configPath: string): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=load-project-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-project-config.d.ts","sourceRoot":"","sources":["../../src/utils/load-project-config.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCzE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { importProjectTypescript } from './import-typescript.js';
|
|
3
|
+
import { logger } from './logger.js';
|
|
4
|
+
/**
|
|
5
|
+
* Load `prenta.config.ts` and register its storage adapter so media commands
|
|
6
|
+
* can download private blobs. A missing or unloadable config falls through
|
|
7
|
+
* to a public-URL fetch.
|
|
8
|
+
*/
|
|
9
|
+
export async function loadProjectConfig(configPath) {
|
|
10
|
+
try {
|
|
11
|
+
const { setPrentaConfig, setStorageAdapter, autoWireStorageAdapter } = await import('@prenta/core');
|
|
12
|
+
const mod = (await importProjectTypescript(resolve(configPath)));
|
|
13
|
+
const config = mod.default ?? mod.config;
|
|
14
|
+
if (!config || typeof config !== 'object')
|
|
15
|
+
return;
|
|
16
|
+
setPrentaConfig(config);
|
|
17
|
+
const platformStorage = config.platform?.storage;
|
|
18
|
+
if (platformStorage &&
|
|
19
|
+
typeof platformStorage === 'object' &&
|
|
20
|
+
typeof platformStorage.upload === 'function') {
|
|
21
|
+
setStorageAdapter(platformStorage);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const provider = platformStorage &&
|
|
25
|
+
typeof platformStorage === 'object' &&
|
|
26
|
+
typeof platformStorage.provider === 'string'
|
|
27
|
+
? platformStorage.provider
|
|
28
|
+
: undefined;
|
|
29
|
+
if (provider)
|
|
30
|
+
await autoWireStorageAdapter(provider);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
logger.warn(`Could not load ${configPath} β will fetch public media URLs directly. ` +
|
|
34
|
+
'Pass --config if uploads go through a private storage adapter.');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=load-project-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-project-config.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;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prenta/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "CLI for Prenta CMS β migrations, codegen, imports, exports, and upgrades",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@vercel/blob": "^2.3.1",
|
|
37
37
|
"typescript": "^5.7.0",
|
|
38
38
|
"vitest": "^4.1.0",
|
|
39
|
-
"@prenta/core": "7.1
|
|
39
|
+
"@prenta/core": "7.5.1"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import ora from 'ora'
|
|
3
|
+
import { connectProjectDatabase } from '../utils/database.js'
|
|
4
|
+
import { loadProjectConfig } from '../utils/load-project-config.js'
|
|
5
|
+
import { loadProjectEnv } from '../utils/load-dotenv.js'
|
|
6
|
+
import { logger } from '../utils/logger.js'
|
|
7
|
+
|
|
8
|
+
interface MigrateContentHashOptions {
|
|
9
|
+
dryRun?: boolean
|
|
10
|
+
limit?: string
|
|
11
|
+
batchSize?: string
|
|
12
|
+
config?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function parsePositiveInt(raw: string | undefined, flag: string): number | undefined {
|
|
16
|
+
if (raw === undefined) return undefined
|
|
17
|
+
const value = Number.parseInt(raw, 10)
|
|
18
|
+
if (!Number.isFinite(value) || value <= 0 || String(value) !== raw.trim()) {
|
|
19
|
+
logger.error(`${flag} must be a positive integer.`)
|
|
20
|
+
process.exit(1)
|
|
21
|
+
}
|
|
22
|
+
return value
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** `prenta migrate:content-hash` β fill Media.contentHash so upload dedupe can match legacy files. */
|
|
26
|
+
async function runMigrateContentHash(options: MigrateContentHashOptions): Promise<void> {
|
|
27
|
+
const dryRun = options.dryRun ?? false
|
|
28
|
+
const limit = parsePositiveInt(options.limit, '--limit')
|
|
29
|
+
const batchSize = parsePositiveInt(options.batchSize, '--batch-size')
|
|
30
|
+
|
|
31
|
+
await loadProjectEnv(process.cwd()).then((env) => {
|
|
32
|
+
for (const [key, value] of Object.entries(env)) {
|
|
33
|
+
if (value !== undefined && process.env[key] === undefined) {
|
|
34
|
+
process.env[key] = value
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
await loadProjectConfig(options.config ?? 'prenta.config.ts')
|
|
39
|
+
|
|
40
|
+
let connection: { db: unknown; disconnect: () => Promise<void> } | null = null
|
|
41
|
+
const spinner = ora(
|
|
42
|
+
dryRun ? 'Hashing media library (dry run)β¦' : 'Backfilling media content hashesβ¦',
|
|
43
|
+
).start()
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
connection = await connectProjectDatabase()
|
|
47
|
+
const { backfillMediaContentHash } = await import('@prenta/core')
|
|
48
|
+
|
|
49
|
+
const result = await backfillMediaContentHash(connection.db as never, {
|
|
50
|
+
dryRun,
|
|
51
|
+
limit,
|
|
52
|
+
batchSize,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
spinner.succeed(
|
|
56
|
+
dryRun
|
|
57
|
+
? `Dry run complete β ${result.hashed} asset(s) would be hashed.`
|
|
58
|
+
: `Hashed ${result.hashed} asset(s).`,
|
|
59
|
+
)
|
|
60
|
+
logger.info(` Scanned: ${result.scanned}`)
|
|
61
|
+
logger.info(` Hashed: ${result.hashed}`)
|
|
62
|
+
logger.info(` Failed: ${result.failed}`)
|
|
63
|
+
logger.info(` Remaining: ${result.remaining}`)
|
|
64
|
+
logger.info(` Collisions: ${result.collisions.length}`)
|
|
65
|
+
if (result.collisions.length > 0) {
|
|
66
|
+
logger.info('')
|
|
67
|
+
logger.info('Byte-identical groups (not merged β resolve these by hand):')
|
|
68
|
+
for (const group of result.collisions.slice(0, 20)) {
|
|
69
|
+
logger.info(` ${group.mediaIds.join(', ')}`)
|
|
70
|
+
}
|
|
71
|
+
if (result.collisions.length > 20) {
|
|
72
|
+
logger.info(` β¦and ${result.collisions.length - 20} more`)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (result.errors.length > 0) {
|
|
76
|
+
logger.info('')
|
|
77
|
+
for (const err of result.errors.slice(0, 10)) {
|
|
78
|
+
logger.info(` ${err.id}: ${err.message}`)
|
|
79
|
+
}
|
|
80
|
+
if (result.errors.length > 10) {
|
|
81
|
+
logger.info(` β¦and ${result.errors.length - 10} more`)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (result.remaining > 0 && !dryRun) {
|
|
85
|
+
logger.info('')
|
|
86
|
+
logger.info('Re-run to continue. Rows that already have a hash are skipped.')
|
|
87
|
+
}
|
|
88
|
+
} catch (err) {
|
|
89
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
90
|
+
spinner.fail(`Content hash backfill failed: ${message}`)
|
|
91
|
+
process.exit(1)
|
|
92
|
+
} finally {
|
|
93
|
+
await connection?.disconnect()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function registerMigrateContentHashCommand(program: Command): void {
|
|
98
|
+
program
|
|
99
|
+
.command('migrate:content-hash')
|
|
100
|
+
.description(
|
|
101
|
+
'SHA-256 stored bytes onto media rows with a NULL contentHash so upload dedupe can match them. Idempotent. Reports collisions; does not merge or delete.',
|
|
102
|
+
)
|
|
103
|
+
.option('--dry-run', 'Download and report without writing hashes')
|
|
104
|
+
.option('--limit <n>', 'Max assets to download this run')
|
|
105
|
+
.option('--batch-size <n>', 'Media rows per DB page (default 50)')
|
|
106
|
+
.option('--config <path>', 'Path to prenta.config.ts (default: ./prenta.config.ts)')
|
|
107
|
+
.action(runMigrateContentHash)
|
|
108
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
|
-
import { resolve } from 'node:path'
|
|
3
2
|
import ora from 'ora'
|
|
4
3
|
import { connectProjectDatabase } from '../utils/database.js'
|
|
5
|
-
import {
|
|
4
|
+
import { loadProjectConfig } from '../utils/load-project-config.js'
|
|
6
5
|
import { loadProjectEnv } from '../utils/load-dotenv.js'
|
|
7
6
|
import { logger } from '../utils/logger.js'
|
|
8
7
|
|
|
@@ -14,42 +13,6 @@ interface MigrateMediaOptimizeOptions {
|
|
|
14
13
|
config?: string
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
async function loadProjectConfig(configPath: string): Promise<void> {
|
|
18
|
-
try {
|
|
19
|
-
const { setPrentaConfig, setStorageAdapter, autoWireStorageAdapter } =
|
|
20
|
-
await import('@prenta/core')
|
|
21
|
-
const mod = (await importProjectTypescript(resolve(configPath))) as {
|
|
22
|
-
default?: unknown
|
|
23
|
-
config?: unknown
|
|
24
|
-
}
|
|
25
|
-
const config = mod.default ?? mod.config
|
|
26
|
-
if (!config || typeof config !== 'object') return
|
|
27
|
-
setPrentaConfig(config as never)
|
|
28
|
-
|
|
29
|
-
const platformStorage = (config as { platform?: { storage?: unknown } }).platform?.storage
|
|
30
|
-
if (
|
|
31
|
-
platformStorage &&
|
|
32
|
-
typeof platformStorage === 'object' &&
|
|
33
|
-
typeof (platformStorage as { upload?: unknown }).upload === 'function'
|
|
34
|
-
) {
|
|
35
|
-
setStorageAdapter(platformStorage as never)
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
const provider =
|
|
39
|
-
platformStorage &&
|
|
40
|
-
typeof platformStorage === 'object' &&
|
|
41
|
-
typeof (platformStorage as { provider?: unknown }).provider === 'string'
|
|
42
|
-
? (platformStorage as { provider: string }).provider
|
|
43
|
-
: undefined
|
|
44
|
-
if (provider) await autoWireStorageAdapter(provider)
|
|
45
|
-
} catch {
|
|
46
|
-
logger.warn(
|
|
47
|
-
`Could not load ${configPath} β will fetch public media URLs directly. ` +
|
|
48
|
-
'Pass --config if uploads go through a private storage adapter.',
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
16
|
/** `prenta migrate:media-optimize` β re-run WebP/dimension pipeline on existing media. */
|
|
54
17
|
async function runMigrateMediaOptimize(options: MigrateMediaOptimizeOptions): Promise<void> {
|
|
55
18
|
const dryRun = options.dryRun ?? false
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { registerMigrateSchemaCommand } from './commands/migrate-schema.js'
|
|
|
6
6
|
import { registerMigrateMetaCommand } from './commands/migrate-meta.js'
|
|
7
7
|
import { registerMigrateMediaUsageCommand } from './commands/migrate-media-usage.js'
|
|
8
8
|
import { registerMigrateMediaOptimizeCommand } from './commands/migrate-media-optimize.js'
|
|
9
|
+
import { registerMigrateContentHashCommand } from './commands/migrate-content-hash.js'
|
|
9
10
|
import { registerGenerateCommand } from './commands/generate.js'
|
|
10
11
|
import { registerSeedCommand } from './commands/seed.js'
|
|
11
12
|
import { registerImportCommand } from './commands/import.js'
|
|
@@ -39,6 +40,7 @@ registerMigrateSchemaCommand(program)
|
|
|
39
40
|
registerMigrateMetaCommand(program)
|
|
40
41
|
registerMigrateMediaUsageCommand(program)
|
|
41
42
|
registerMigrateMediaOptimizeCommand(program)
|
|
43
|
+
registerMigrateContentHashCommand(program)
|
|
42
44
|
registerGenerateCommand(program)
|
|
43
45
|
registerSeedCommand(program)
|
|
44
46
|
registerImportCommand(program)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import { importProjectTypescript } from './import-typescript.js'
|
|
3
|
+
import { logger } from './logger.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Load `prenta.config.ts` and register its storage adapter so media commands
|
|
7
|
+
* can download private blobs. A missing or unloadable config falls through
|
|
8
|
+
* to a public-URL fetch.
|
|
9
|
+
*/
|
|
10
|
+
export async function loadProjectConfig(configPath: string): Promise<void> {
|
|
11
|
+
try {
|
|
12
|
+
const { setPrentaConfig, setStorageAdapter, autoWireStorageAdapter } =
|
|
13
|
+
await import('@prenta/core')
|
|
14
|
+
const mod = (await importProjectTypescript(resolve(configPath))) as {
|
|
15
|
+
default?: unknown
|
|
16
|
+
config?: unknown
|
|
17
|
+
}
|
|
18
|
+
const config = mod.default ?? mod.config
|
|
19
|
+
if (!config || typeof config !== 'object') return
|
|
20
|
+
setPrentaConfig(config as never)
|
|
21
|
+
|
|
22
|
+
const platformStorage = (config as { platform?: { storage?: unknown } }).platform?.storage
|
|
23
|
+
if (
|
|
24
|
+
platformStorage &&
|
|
25
|
+
typeof platformStorage === 'object' &&
|
|
26
|
+
typeof (platformStorage as { upload?: unknown }).upload === 'function'
|
|
27
|
+
) {
|
|
28
|
+
setStorageAdapter(platformStorage as never)
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
const provider =
|
|
32
|
+
platformStorage &&
|
|
33
|
+
typeof platformStorage === 'object' &&
|
|
34
|
+
typeof (platformStorage as { provider?: unknown }).provider === 'string'
|
|
35
|
+
? (platformStorage as { provider: string }).provider
|
|
36
|
+
: undefined
|
|
37
|
+
if (provider) await autoWireStorageAdapter(provider)
|
|
38
|
+
} catch {
|
|
39
|
+
logger.warn(
|
|
40
|
+
`Could not load ${configPath} β will fetch public media URLs directly. ` +
|
|
41
|
+
'Pass --config if uploads go through a private storage adapter.',
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}
|