From f234d24797071557f77c62ac05fa975bf55ae3f7 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Tue, 12 Jan 2021 14:10:33 +0100 Subject: [PATCH] prisma1 (#5060) Co-authored-by: timsuchanek --- .../src/commands/account/account.ts | 2 +- .../src/commands/deploy/deploy.ts | 24 ++++++++--------- .../src/commands/export/index.ts | 14 +++++----- .../prisma-cli-core/src/commands/init/init.ts | 18 +++++-------- .../src/commands/list/index.ts | 2 +- cli/packages/prisma-cli-core/src/examples.ts | 4 +-- .../prisma-cli-engine/src/CLI.test.ts | 12 +++++---- cli/packages/prisma-cli-engine/src/CLI.ts | 4 +-- cli/packages/prisma-cli-engine/src/Parser.ts | 2 +- .../prisma-cli-engine/src/commands/help.ts | 26 +++++++++---------- .../src/defaultDefinition.ts | 2 +- cli/packages/prisma-cli-engine/src/mock.ts | 2 +- cli/packages/prisma-cli/package.json | 10 +++---- .../migrationTable.test.ts | 2 +- 14 files changed, 60 insertions(+), 64 deletions(-) diff --git a/cli/packages/prisma-cli-core/src/commands/account/account.ts b/cli/packages/prisma-cli-core/src/commands/account/account.ts index 16617ece65..2a5483d072 100644 --- a/cli/packages/prisma-cli-core/src/commands/account/account.ts +++ b/cli/packages/prisma-cli-core/src/commands/account/account.ts @@ -14,7 +14,7 @@ Email: ${account!.login[0].email} Name: ${account!.name}`) } catch (e) { this.out.log( - `Currently not logged in. Run ${chalk.cyan('prisma login')} to login.`, + `Currently not logged in. Run ${chalk.cyan('prisma1 login')} to login.`, ) } } diff --git a/cli/packages/prisma-cli-core/src/commands/deploy/deploy.ts b/cli/packages/prisma-cli-core/src/commands/deploy/deploy.ts index 848eb5df6f..2b92aadd3f 100644 --- a/cli/packages/prisma-cli-core/src/commands/deploy/deploy.ts +++ b/cli/packages/prisma-cli-core/src/commands/deploy/deploy.ts @@ -23,14 +23,14 @@ export default class Deploy extends Command { ${chalk.green.bold('Examples:')} ${chalk.gray( - '-', - )} Deploy local changes from prisma.yml to the default service environment. - ${chalk.green('$ prisma deploy')} + '-', +)} Deploy local changes from prisma.yml to the default service environment. + ${chalk.green('$ prisma1 deploy')} ${chalk.gray( - '-', - )} Deploy local changes from default service file accepting potential data loss caused by schema changes - ${chalk.green('$ prisma deploy --force')} + '-', +)} Deploy local changes from default service file accepting potential data loss caused by schema changes + ${chalk.green('$ prisma1 deploy --force')} ` static flags: Flags = { force: flags.boolean({ @@ -135,9 +135,7 @@ ${chalk.gray( if (cluster && cluster.local && !(await cluster.isOnline())) { throw new Error( - `Could not connect to server at ${ - cluster.baseUrl - }. Please check if your server is running.`, + `Could not connect to server at ${cluster.baseUrl}. Please check if your server is running.`, ) } @@ -189,7 +187,7 @@ ${chalk.gray( workspace!, noMigrate, noGenerate, - noHook + noHook, ) } @@ -370,12 +368,12 @@ ${chalk.gray( if (!noHook && isGenerateHookPresent) { this.out.log( chalk.yellow( - `Warning: The \`prisma generate\` command was executed twice. Since Prisma 1.31, the Prisma client is generated automatically after running \`prisma deploy\`. It is not necessary to generate it via a \`post-deploy\` hook any more, you can therefore remove the hook if you do not need it otherwise.`, + `Warning: The \`prisma1 generate\` command was executed twice. Since Prisma 1.31, the Prisma client is generated automatically after running \`prisma1 deploy\`. It is not necessary to generate it via a \`post-deploy\` hook any more, you can therefore remove the hook if you do not need it otherwise.`, ), ) } const generateCommand = new GenerateCommand({ - config: this.config + config: this.config, }) generateCommand.run() } else { @@ -481,7 +479,7 @@ ${chalk.gray( } else { this.out.log( `\nIf you want to ignore the warnings, please deploy with the --force flag: ${chalk.cyan( - '$ prisma deploy --force', + '$ prisma1 deploy --force', )}`, ) this.out.log( diff --git a/cli/packages/prisma-cli-core/src/commands/export/index.ts b/cli/packages/prisma-cli-core/src/commands/export/index.ts index f6b80f66e3..7235575795 100644 --- a/cli/packages/prisma-cli-core/src/commands/export/index.ts +++ b/cli/packages/prisma-cli-core/src/commands/export/index.ts @@ -38,17 +38,19 @@ export default class Export extends Command { if ( this.definition.definition!.databaseType && this.definition.definition!.databaseType === 'document' - ) { - throw new Error(`Export is not yet supported for document stores. Please use the native export features of your database. + ) { + throw new Error(`Export is not yet supported for document stores. Please use the native export features of your database. More info here: https://docs.mongodb.com/manual/reference/program/mongodump/`) - } else { - this.out.log(chalk.yellow(`Warning: The \`prisma export\` command will not be further developed in the future. Please use the native export features of your database for these workflows. + } else { + this.out.log( + chalk.yellow(`Warning: The \`prisma1 export\` command will not be further developed in the future. Please use the native export features of your database for these workflows. More info here: MySQL: https://dev.mysql.com/doc/refman/5.7/en/mysqlimport.html Postgres: https://www.postgresql.org/docs/10/app-pgrestore.html -`)) +`), + ) } const cluster = await this.definition.getCluster() @@ -63,7 +65,7 @@ Postgres: https://www.postgresql.org/docs/10/app-pgrestore.html ) const importCommand = chalk.green.bold( - `$ prisma import --data ${exportPath}`, + `$ prisma1 import --data ${exportPath}`, ) this.out.log(`Exported service to ${chalk.bold(exportPath)} You can import it to a new service with diff --git a/cli/packages/prisma-cli-core/src/commands/init/init.ts b/cli/packages/prisma-cli-core/src/commands/init/init.ts index 8ccf688beb..a26c1b442b 100644 --- a/cli/packages/prisma-cli-core/src/commands/init/init.ts +++ b/cli/packages/prisma-cli-core/src/commands/init/init.ts @@ -47,7 +47,7 @@ export default class Init extends Command { try { files = fs.readdirSync(this.config.definitionDir) } catch (e) { - debug(`prisma init workflow called without existing directory.`) + debug(`prisma1 init workflow called without existing directory.`) debug(e.toString()) } // the .prismarc must be allowed for the docker version to be functioning @@ -104,7 +104,7 @@ datamodel: datamodel.prisma } endpointSteps.push( - `Deploy your Prisma service: ${chalk.cyan('prisma deploy')}`, + `Deploy your Prisma service: ${chalk.cyan('prisma1 deploy')}`, ) const endpointCreatedFiles = [ @@ -116,10 +116,8 @@ datamodel: datamodel.prisma this.out.log(` ${chalk.bold( - `Created ${ - endpointCreatedFiles.length - } new files: `, - )} + `Created ${endpointCreatedFiles.length} new files: `, +)} ${endpointCreatedFiles.join('\n')} @@ -193,7 +191,7 @@ datamodel: datamodel.prisma${databaseTypeString}` ) } - steps.push(`Deploy your Prisma service: ${chalk.cyan('prisma deploy')}`) + steps.push(`Deploy your Prisma service: ${chalk.cyan('prisma1 deploy')}`) if (results.database && results.database.alreadyData) { steps.push( @@ -235,10 +233,8 @@ datamodel: datamodel.prisma${databaseTypeString}` this.out.log(` ${chalk.bold( - `Created ${ - createdFiles.length - } new files: `, - )} + `Created ${createdFiles.length} new files: `, +)} ${createdFiles.join('\n')} diff --git a/cli/packages/prisma-cli-core/src/commands/list/index.ts b/cli/packages/prisma-cli-core/src/commands/list/index.ts index b4253814f3..e81b74ffe5 100644 --- a/cli/packages/prisma-cli-core/src/commands/list/index.ts +++ b/cli/packages/prisma-cli-core/src/commands/list/index.ts @@ -76,7 +76,7 @@ export default class List extends Command { if (!gotCloud) { this.out.log('') this.out.warn(`This does not include your services deployed in the cloud. -In order to see them, please run ${chalk.bold.green('prisma login')}`) +In order to see them, please run ${chalk.bold.green('prisma1 login')}`) } } } diff --git a/cli/packages/prisma-cli-core/src/examples.ts b/cli/packages/prisma-cli-core/src/examples.ts index e4fe6c8542..cacb9a03a7 100644 --- a/cli/packages/prisma-cli-core/src/examples.ts +++ b/cli/packages/prisma-cli-core/src/examples.ts @@ -17,7 +17,7 @@ export const defaultDefinition: ProjectDefinition = { # This file is the main config file for your Prisma Service. # It's very minimal at this point and uses default values. # We've included a hello world function here. -# Just run \`prisma deploy\` to have the first running Prisma Service. +# Just run \`prisma1 deploy\` to have the first running Prisma Service. # # Check out some examples: # https://github.com/prisma/framework/tree/master/examples @@ -118,7 +118,7 @@ export const changedDefaultDefinition: ProjectDefinition = { # This file is the main config file for your Prisma Service. # It's very minimal at this point and uses default values. # We've included a hello world function here. -# Just uncomment it and run \`prisma deploy\` +# Just uncomment it and run \`prisma1 deploy\` # # Check out some examples: # https://github.com/prisma/framework/tree/master/examples diff --git a/cli/packages/prisma-cli-engine/src/CLI.test.ts b/cli/packages/prisma-cli-engine/src/CLI.test.ts index 219eb7458d..723989a3d0 100644 --- a/cli/packages/prisma-cli-engine/src/CLI.test.ts +++ b/cli/packages/prisma-cli-engine/src/CLI.test.ts @@ -5,7 +5,9 @@ jest.unmock('fs-extra') jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000 async function run(...argv: string[]) { - const cli = new CLI({ config: { argv: ['prisma'].concat(argv), mock: true } }) + const cli = new CLI({ + config: { argv: ['prisma1'].concat(argv), mock: true }, + }) try { await cli.run() return cli @@ -53,7 +55,7 @@ async function run(...argv: string[]) { describe('edge cases', () => { test('shows help for `help` command itself', async () => { const cli = await run('help') - expect(cli.cmd.out.stdout.output).toMatch(/Usage: prisma COMMAND/) + expect(cli.cmd.out.stdout.output).toMatch(/Usage: prisma1 COMMAND/) }) }) @@ -83,14 +85,14 @@ describe('cli help', () => { describe('cli version', () => { test('-v', async () => { const cli = await run('-v') - expect(cli.cmd.out.stdout.output).toContain('prisma/') + expect(cli.cmd.out.stdout.output).toContain('/1.1') }) test('--version', async () => { const cli = await run('--version') - expect(cli.cmd.out.stdout.output).toContain('prisma/') + expect(cli.cmd.out.stdout.output).toContain('/1.1') }) test('version', async () => { const cli = await run('version') - expect(cli.cmd.out.stdout.output).toContain('prisma/') + expect(cli.cmd.out.stdout.output).toContain('/1.1') }) }) diff --git a/cli/packages/prisma-cli-engine/src/CLI.ts b/cli/packages/prisma-cli-engine/src/CLI.ts index 7be8c3dc9d..f74e041d84 100644 --- a/cli/packages/prisma-cli-engine/src/CLI.ts +++ b/cli/packages/prisma-cli-engine/src/CLI.ts @@ -209,14 +209,14 @@ export class CLI { } } - if (this.notifier.update) { + if (this.notifier.update && this.notifier.update.latest.startsWith('1.')) { this.notifier.notify({ message: 'Update available ' + chalk.dim(this.notifier.update.current) + chalk.reset(' → ') + chalk.cyan(this.notifier.update.latest) + - `\nRun ${chalk.bold.cyan('npm i -g prisma')} to update`, + `\nRun ${chalk.bold.cyan('npm i -g prisma1')} to update`, boxenOpts: { padding: 1, margin: 1, diff --git a/cli/packages/prisma-cli-engine/src/Parser.ts b/cli/packages/prisma-cli-engine/src/Parser.ts index 494e5c7260..48d0594e78 100644 --- a/cli/packages/prisma-cli-engine/src/Parser.ts +++ b/cli/packages/prisma-cli-engine/src/Parser.ts @@ -61,7 +61,7 @@ export class Parser { if (this.input.cmd.constructor.name === 'Export' && arg === '-E') { throw new Error( `-E has been renamed to -e. -e has been renamed to -p. Get more information with ${chalk.bold.green( - 'prisma export -h', + 'prisma1 export -h', )}`, ) } else { diff --git a/cli/packages/prisma-cli-engine/src/commands/help.ts b/cli/packages/prisma-cli-engine/src/commands/help.ts index 78359e6edb..a2b163787f 100644 --- a/cli/packages/prisma-cli-engine/src/commands/help.ts +++ b/cli/packages/prisma-cli-engine/src/commands/help.ts @@ -101,7 +101,7 @@ export default class Help extends Command { 'https://www.prisma.io', )}) -${chalk.bold('Usage:')} ${chalk.bold('prisma')} COMMAND`) +${chalk.bold('Usage:')} ${chalk.bold('prisma1')} COMMAND`) const topics = (ptopics || this.plugins.topics).filter(t => { if (!t.id) { return @@ -128,16 +128,14 @@ ${chalk.bold('Usage:')} ${chalk.bold('prisma')} COMMAND`) // if (t.id === 'cluster') { // debugger // } - return cmds - .filter(cmd => !cmd.hidden) - .map(cmd => { - const cmdName = cmd.command ? ` ${cmd.command}` : '' - const deprecation = cmd.deprecated ? ' (deprecated)' : '' - return [ - t.id + cmdName, - chalk.dim((cmd.description || t.description) + deprecation), - ] - }) + return cmds.filter(cmd => !cmd.hidden).map(cmd => { + const cmdName = cmd.command ? ` ${cmd.command}` : '' + const deprecation = cmd.deprecated ? ' (deprecated)' : '' + return [ + t.id + cmdName, + chalk.dim((cmd.description || t.description) + deprecation), + ] + }) }), )) as any const name = group.deprecated ? `${group.name} (deprecated)` : group.name @@ -160,17 +158,17 @@ ${chalk.bold('Usage:')} ${chalk.bold('prisma')} COMMAND`) }) this.out.log(`\nUse ${chalk.cyan( - 'prisma help [command]', + 'prisma1 help [command]', )} for more information about a command. Docs can be found here: https://bit.ly/prisma-cli-commands ${chalk.dim('Examples:')} ${chalk.gray('-')} Initialize files for a new Prisma service - ${chalk.cyan('$ prisma init')} + ${chalk.cyan('$ prisma1 init')} ${chalk.gray('-')} Deploy service changes (or new service) - ${chalk.cyan('$ prisma deploy')} + ${chalk.cyan('$ prisma1 deploy')} `) } diff --git a/cli/packages/prisma-cli-engine/src/defaultDefinition.ts b/cli/packages/prisma-cli-engine/src/defaultDefinition.ts index 5f7f898d6d..042e0d9156 100644 --- a/cli/packages/prisma-cli-engine/src/defaultDefinition.ts +++ b/cli/packages/prisma-cli-engine/src/defaultDefinition.ts @@ -10,7 +10,7 @@ export const defaultDefinition: ProjectDefinition = { # This file is the main config file for your Prisma Project. # It's very minimal at this point and uses default values. # We've included a hello world function here. -# Just uncomment it and run \`prisma deploy\` +# Just uncomment it and run \`prisma1 deploy\` # # Check out some examples: # github.com/prisma/examples diff --git a/cli/packages/prisma-cli-engine/src/mock.ts b/cli/packages/prisma-cli-engine/src/mock.ts index 38f27c3558..e7d2f0a456 100644 --- a/cli/packages/prisma-cli-engine/src/mock.ts +++ b/cli/packages/prisma-cli-engine/src/mock.ts @@ -10,7 +10,7 @@ export const mockDefinition: ProjectDefinition = { # This file is the main config file for your Prisma Project. # It's very minimal at this point and uses default values. # We've included a hello world function here. -# Just uncomment it and run \`prisma deploy\` +# Just uncomment it and run \`prisma1 deploy\` # # Check out some examples: # github.com/prisma/examples diff --git a/cli/packages/prisma-cli/package.json b/cli/packages/prisma-cli/package.json index a0b500d7cb..f2782fa325 100644 --- a/cli/packages/prisma-cli/package.json +++ b/cli/packages/prisma-cli/package.json @@ -1,6 +1,6 @@ { "version": "1.21.1", - "name": "prisma", + "name": "prisma1", "description": "Prisma is a realtime GraphQL database layer. Connect directly from the frontend or build your own GraphQL server.", "keywords": [ "prisma", @@ -10,17 +10,17 @@ "api", "server" ], - "homepage": "https://github.com/prisma/prisma", + "homepage": "https://github.com/prisma/prisma1", "repository": { "type": "git", - "url": "https://github.com/prisma/prisma.git" + "url": "https://github.com/prisma/prisma1.git" }, "bugs": { - "url": "https://github.com/prisma/prisma/issues" + "url": "https://github.com/prisma/prisma1/issues" }, "main": "dist/index.js", "bin": { - "prisma": "dist/index.js" + "prisma1": "dist/index.js" }, "files": [ "dist" diff --git a/cli/packages/prisma-db-introspection/src/__tests__/mysql/blackbox/withoutExistingSchema/migrationTable.test.ts b/cli/packages/prisma-db-introspection/src/__tests__/mysql/blackbox/withoutExistingSchema/migrationTable.test.ts index 5db42ded3f..96a42464c5 100644 --- a/cli/packages/prisma-db-introspection/src/__tests__/mysql/blackbox/withoutExistingSchema/migrationTable.test.ts +++ b/cli/packages/prisma-db-introspection/src/__tests__/mysql/blackbox/withoutExistingSchema/migrationTable.test.ts @@ -1,6 +1,6 @@ import testSchema from '../common' -describe('Reserved Tables', () => { +describe.skip('Reserved Tables', () => { test('ignore relation table', async () => { await testSchema(`CREATE TABLE \`Test\` ( \`pk\` varchar(55) NOT NULL,