mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
feat(db): add support for pass-through astro db
command
This commit is contained in:
parent
4b4954e890
commit
b8d19f93a1
7 changed files with 20 additions and 12 deletions
|
@ -183,6 +183,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/check": "^0.3.1",
|
||||
"@astrojs/db": "workspace:*",
|
||||
"@playwright/test": "1.40.0",
|
||||
"@types/aria-query": "^5.0.4",
|
||||
"@types/babel__generator": "^7.6.7",
|
||||
|
|
|
@ -30,6 +30,7 @@ async function printAstroHelp() {
|
|||
['add', 'Add an integration.'],
|
||||
['build', 'Build your project and write it to disk.'],
|
||||
['check', 'Check your project for errors.'],
|
||||
['db', 'Manage your Astro database.'],
|
||||
['dev', 'Start the development server.'],
|
||||
['docs', 'Open documentation in your web browser.'],
|
||||
['info', 'List info about your current Astro setup.'],
|
||||
|
|
|
@ -20,7 +20,8 @@ export async function getPackage<T>(
|
|||
): Promise<T | undefined> {
|
||||
let packageImport;
|
||||
try {
|
||||
await tryResolve(packageName, options.cwd ?? process.cwd());
|
||||
// TODO: uncomment this when `@astrojs/db` works
|
||||
// await tryResolve(packageName, options.cwd ?? process.cwd());
|
||||
|
||||
// The `require.resolve` is required as to avoid Node caching the failed `import`
|
||||
packageImport = await import(packageName);
|
||||
|
|
|
@ -31,14 +31,14 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"bin": {
|
||||
"studio": "./dist/cli/bin.js"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dist",
|
||||
"components"
|
||||
],
|
||||
"bin": {
|
||||
"studio": "./dist/cli/index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
|
||||
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
||||
|
|
9
packages/db/src/cli/bin.ts
Normal file
9
packages/db/src/cli/bin.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env node
|
||||
import { cli } from './index.js';
|
||||
|
||||
async function main() {
|
||||
const [command, ...args] = process.argv.slice(2);
|
||||
await cli(command, args);
|
||||
}
|
||||
|
||||
await main();
|
|
@ -1,13 +1,10 @@
|
|||
#!/usr/bin/env node
|
||||
import { red } from 'kleur/colors';
|
||||
import { astroConfigWithDbSchema } from '../config.js';
|
||||
import { errorMap } from '../error-map.js';
|
||||
import { loadAstroConfig } from '../load-astro-config.js';
|
||||
|
||||
async function main() {
|
||||
const cmd = process.argv[2];
|
||||
|
||||
switch (cmd) {
|
||||
export async function cli(command: string, _args: string[] = []) {
|
||||
switch (command) {
|
||||
case 'sync': {
|
||||
const { sync } = await import('./sync/index.js');
|
||||
const astroConfig = await getAstroConfigOrExit();
|
||||
|
@ -18,7 +15,7 @@ async function main() {
|
|||
}
|
||||
default: {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`Unknown command: ${cmd}`);
|
||||
console.error(`Unknown command: ${command}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -37,5 +34,3 @@ async function getAstroConfigOrExit(root: string = process.cwd()) {
|
|||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
await main();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
export { defineCollection, defineWritableCollection, field } from './config.js';
|
||||
|
||||
export { cli } from './cli/index.js';
|
||||
export { integration as default } from './integration.js';
|
||||
|
|
Loading…
Reference in a new issue