diff --git a/packages/schema/src/cli/index.ts b/packages/schema/src/cli/index.ts index d96ed1121..f4fee92b7 100644 --- a/packages/schema/src/cli/index.ts +++ b/packages/schema/src/cli/index.ts @@ -81,7 +81,6 @@ export function createProgram() { `schema file (with extension ${schemaExtensions}). Defaults to "schema.zmodel" unless specified in package.json.` ); - const configOption = new Option('-c, --config [file]', 'config file').hideHelp(); const pmOption = new Option('-p, --package-manager ', 'package manager to use').choices([ 'npm', 'yarn', @@ -99,7 +98,6 @@ export function createProgram() { program .command('init') .description('Initialize an existing project for ZenStack.') - .addOption(configOption) .addOption(pmOption) .addOption(new Option('--prisma ', 'location of Prisma schema file to bootstrap from')) .addOption(new Option('--tag ', 'the NPM package tag to use when installing dependencies')) diff --git a/packages/schema/src/plugins/prisma/schema-generator.ts b/packages/schema/src/plugins/prisma/schema-generator.ts index 01a8efc60..bfc0cf770 100644 --- a/packages/schema/src/plugins/prisma/schema-generator.ts +++ b/packages/schema/src/plugins/prisma/schema-generator.ts @@ -142,7 +142,7 @@ export class PrismaSchemaGenerator { if (options.format === true) { try { // run 'prisma format' - await execSync(`npx prisma format --schema ${outFile}`); + await execSync(`npx prisma format --schema ${outFile}`, { stdio: 'ignore' }); } catch { warnings.push(`Failed to format Prisma schema file`); } diff --git a/tests/integration/tests/cli/config.test.ts b/tests/integration/tests/cli/config.test.ts deleted file mode 100644 index f047889fd..000000000 --- a/tests/integration/tests/cli/config.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -/// - -import * as fs from 'fs'; -import * as tmp from 'tmp'; -import { createProgram } from '../../../../packages/schema/src/cli'; - -describe('CLI Config Tests', () => { - let origDir: string; - - beforeEach(() => { - origDir = process.cwd(); - const r = tmp.dirSync({ unsafeCleanup: true }); - console.log(`Project dir: ${r.name}`); - process.chdir(r.name); - - fs.writeFileSync('package.json', JSON.stringify({ name: 'my app', version: '1.0.0' })); - }); - - afterEach(() => { - process.chdir(origDir); - }); - - // for ensuring backward compatibility only - it('valid default config empty', async () => { - fs.writeFileSync('zenstack.config.json', JSON.stringify({})); - const program = createProgram(); - await program.parseAsync(['init', '--tag', 'latest'], { from: 'user' }); - }); - - // for ensuring backward compatibility only - it('valid default config non-empty', async () => { - fs.writeFileSync( - 'zenstack.config.json', - JSON.stringify({ guardFieldName: 'myGuardField', transactionFieldName: 'myTransactionField' }) - ); - - const program = createProgram(); - await program.parseAsync(['init', '--tag', 'latest'], { from: 'user' }); - }); - - it('custom config file does not exist', async () => { - const program = createProgram(); - const configFile = `my.config.json`; - await expect( - program.parseAsync(['init', '--tag', 'latest', '--config', configFile], { from: 'user' }) - ).rejects.toThrow(/Config file could not be found/i); - }); - - it('custom config file is not json', async () => { - const program = createProgram(); - const configFile = `my.config.json`; - fs.writeFileSync(configFile, ` 😬 😬 😬`); - await expect( - program.parseAsync(['init', '--tag', 'latest', '--config', configFile], { from: 'user' }) - ).rejects.toThrow(/Config is not a valid JSON file/i); - }); - - // for ensuring backward compatibility only - it('valid custom config file', async () => { - fs.writeFileSync('my.config.json', JSON.stringify({ guardFieldName: 'myGuardField' })); - const program = createProgram(); - await program.parseAsync(['init', '--tag', 'latest', '--config', 'my.config.json'], { from: 'user' }); - }); -});