mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
wip: db action
This commit is contained in:
parent
f66b9df1c2
commit
ff0dca3b6f
3 changed files with 53 additions and 8 deletions
|
@ -47,6 +47,7 @@
|
||||||
"test:match": "mocha --timeout 20000 -g"
|
"test:match": "mocha --timeout 20000 -g"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.10.1",
|
||||||
"@libsql/client": "0.4.0-pre.5",
|
"@libsql/client": "0.4.0-pre.5",
|
||||||
"deep-diff": "^1.0.2",
|
"deep-diff": "^1.0.2",
|
||||||
"drizzle-orm": "^0.28.6",
|
"drizzle-orm": "^0.28.6",
|
||||||
|
@ -57,12 +58,12 @@
|
||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/chai": "^4.3.6",
|
||||||
"@types/deep-diff": "^1.0.5",
|
"@types/deep-diff": "^1.0.5",
|
||||||
"@types/diff": "^5.0.8",
|
"@types/diff": "^5.0.8",
|
||||||
"@types/yargs-parser": "^21.0.3",
|
|
||||||
"@types/chai": "^4.3.6",
|
|
||||||
"@types/mocha": "^10.0.2",
|
"@types/mocha": "^10.0.2",
|
||||||
"@types/prompts": "^2.4.8",
|
"@types/prompts": "^2.4.8",
|
||||||
|
"@types/yargs-parser": "^21.0.3",
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
"astro-scripts": "workspace:*",
|
"astro-scripts": "workspace:*",
|
||||||
"chai": "^4.3.10",
|
"chai": "^4.3.10",
|
||||||
|
|
|
@ -5,9 +5,13 @@ import { getMigrations, initializeFromMigrations } from '../../../migrations.js'
|
||||||
const { diff } = deepDiff;
|
const { diff } = deepDiff;
|
||||||
|
|
||||||
export async function cmd({ config }: { config: AstroConfig; flags: Arguments }) {
|
export async function cmd({ config }: { config: AstroConfig; flags: Arguments }) {
|
||||||
|
const core = await isGithubActions();
|
||||||
const currentSnapshot = JSON.parse(JSON.stringify(config.db?.collections ?? {}));
|
const currentSnapshot = JSON.parse(JSON.stringify(config.db?.collections ?? {}));
|
||||||
const allMigrationFiles = await getMigrations();
|
const allMigrationFiles = await getMigrations();
|
||||||
if (allMigrationFiles.length === 0) {
|
if (allMigrationFiles.length === 0) {
|
||||||
|
if (core) {
|
||||||
|
core.setFailed(`Project not yet initialized!`);
|
||||||
|
}
|
||||||
console.log('Project not yet initialized!');
|
console.log('Project not yet initialized!');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -15,9 +19,25 @@ export async function cmd({ config }: { config: AstroConfig; flags: Arguments })
|
||||||
const prevSnapshot = await initializeFromMigrations(allMigrationFiles);
|
const prevSnapshot = await initializeFromMigrations(allMigrationFiles);
|
||||||
const calculatedDiff = diff(prevSnapshot, currentSnapshot);
|
const calculatedDiff = diff(prevSnapshot, currentSnapshot);
|
||||||
if (calculatedDiff) {
|
if (calculatedDiff) {
|
||||||
|
if (core) {
|
||||||
|
core.setFailed(`Schema changes detected!`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
console.log('Changes detected!');
|
console.log('Changes detected!');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
if (core) {
|
||||||
|
core.info('No changes detected!');
|
||||||
|
}
|
||||||
console.log('No changes detected.');
|
console.log('No changes detected.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function isGithubActions(): Promise<typeof import('@actions/core') | undefined> {
|
||||||
|
if (process.env['GITHUB_ACTIONS'] === 'true') {
|
||||||
|
return import('@actions/core').then(res => res.default)
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
36
pnpm-lock.yaml
generated
36
pnpm-lock.yaml
generated
|
@ -3790,6 +3790,9 @@ importers:
|
||||||
|
|
||||||
packages/db:
|
packages/db:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@actions/core':
|
||||||
|
specifier: ^1.10.1
|
||||||
|
version: 1.10.1
|
||||||
'@libsql/client':
|
'@libsql/client':
|
||||||
specifier: 0.4.0-pre.5
|
specifier: 0.4.0-pre.5
|
||||||
version: 0.4.0-pre.5
|
version: 0.4.0-pre.5
|
||||||
|
@ -3907,7 +3910,7 @@ importers:
|
||||||
version: 1.6.17
|
version: 1.6.17
|
||||||
preact:
|
preact:
|
||||||
specifier: ^10.6.5
|
specifier: ^10.6.5
|
||||||
version: 10.19.2
|
version: 10.19.3
|
||||||
simple-stack-form:
|
simple-stack-form:
|
||||||
specifier: ^0.1.10
|
specifier: ^0.1.10
|
||||||
version: 0.1.10(astro@packages+astro)(zod@3.22.4)
|
version: 0.1.10(astro@packages+astro)(zod@3.22.4)
|
||||||
|
@ -5413,6 +5416,20 @@ packages:
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@actions/core@1.10.1:
|
||||||
|
resolution: {integrity: sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==}
|
||||||
|
dependencies:
|
||||||
|
'@actions/http-client': 2.2.0
|
||||||
|
uuid: 8.3.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/@actions/http-client@2.2.0:
|
||||||
|
resolution: {integrity: sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==}
|
||||||
|
dependencies:
|
||||||
|
tunnel: 0.0.6
|
||||||
|
undici: 5.28.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@alloc/quick-lru@5.2.0:
|
/@alloc/quick-lru@5.2.0:
|
||||||
resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}
|
resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -7055,7 +7072,6 @@ packages:
|
||||||
/@fastify/busboy@2.1.0:
|
/@fastify/busboy@2.1.0:
|
||||||
resolution: {integrity: sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==}
|
resolution: {integrity: sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==}
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@fontsource/monofett@5.0.17:
|
/@fontsource/monofett@5.0.17:
|
||||||
resolution: {integrity: sha512-MTSxMPkTXeqEVeaugMh9nUbSqL/0tm0KlwdTInRv3s1JY3S7rzM1hnue+m8p1ZU89viNNjeCBTLaE77MosKdjQ==}
|
resolution: {integrity: sha512-MTSxMPkTXeqEVeaugMh9nUbSqL/0tm0KlwdTInRv3s1JY3S7rzM1hnue+m8p1ZU89viNNjeCBTLaE77MosKdjQ==}
|
||||||
|
@ -14139,10 +14155,6 @@ packages:
|
||||||
preact: 10.19.3
|
preact: 10.19.3
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/preact@10.19.2:
|
|
||||||
resolution: {integrity: sha512-UA9DX/OJwv6YwP9Vn7Ti/vF80XL+YA5H2l7BpCtUr3ya8LWHFzpiO5R+N7dN16ujpIxhekRFuOOF82bXX7K/lg==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/preact@10.19.3:
|
/preact@10.19.3:
|
||||||
resolution: {integrity: sha512-nHHTeFVBTHRGxJXKkKu5hT8C/YWBkPso4/Gad6xuj5dbptt9iF9NZr9pHbPhBrnT2klheu7mHTxTZ/LjwJiEiQ==}
|
resolution: {integrity: sha512-nHHTeFVBTHRGxJXKkKu5hT8C/YWBkPso4/Gad6xuj5dbptt9iF9NZr9pHbPhBrnT2klheu7mHTxTZ/LjwJiEiQ==}
|
||||||
|
|
||||||
|
@ -15832,6 +15844,11 @@ packages:
|
||||||
safe-buffer: 5.2.1
|
safe-buffer: 5.2.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/tunnel@0.0.6:
|
||||||
|
resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==}
|
||||||
|
engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/turbo-darwin-64@1.11.2:
|
/turbo-darwin-64@1.11.2:
|
||||||
resolution: {integrity: sha512-toFmRG/adriZY3hOps7nYCfqHAS+Ci6xqgX3fbo82kkLpC6OBzcXnleSwuPqjHVAaRNhVoB83L5njcE9Qwi2og==}
|
resolution: {integrity: sha512-toFmRG/adriZY3hOps7nYCfqHAS+Ci6xqgX3fbo82kkLpC6OBzcXnleSwuPqjHVAaRNhVoB83L5njcE9Qwi2og==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
|
@ -16036,6 +16053,13 @@ packages:
|
||||||
/undici-types@5.26.5:
|
/undici-types@5.26.5:
|
||||||
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
|
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
|
||||||
|
|
||||||
|
/undici@5.28.2:
|
||||||
|
resolution: {integrity: sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==}
|
||||||
|
engines: {node: '>=14.0'}
|
||||||
|
dependencies:
|
||||||
|
'@fastify/busboy': 2.1.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/undici@6.2.1:
|
/undici@6.2.1:
|
||||||
resolution: {integrity: sha512-7Wa9thEM6/LMnnKtxJHlc8SrTlDmxqJecgz1iy8KlsN0/iskQXOQCuPkrZLXbElPaSw5slFFyKIKXyJ3UtbApw==}
|
resolution: {integrity: sha512-7Wa9thEM6/LMnnKtxJHlc8SrTlDmxqJecgz1iy8KlsN0/iskQXOQCuPkrZLXbElPaSw5slFFyKIKXyJ3UtbApw==}
|
||||||
engines: {node: '>=18.0'}
|
engines: {node: '>=18.0'}
|
||||||
|
|
Loading…
Add table
Reference in a new issue