From 71292ddd2af1e46dc9e02074c09b15b387b31bbb Mon Sep 17 00:00:00 2001 From: Danny Browning Date: Thu, 30 Nov 2023 13:34:16 -0700 Subject: [PATCH] fix: create deploys by default, no index flag for deploy, update docs --- packages/cli/src/commands/composite/create.ts | 2 +- packages/cli/src/commands/composite/deploy.ts | 21 ++++------------ packages/cli/test/composites.test.ts | 24 ------------------- website/docs/api/commands/cli.composite.md | 13 ++++++++-- 4 files changed, 16 insertions(+), 44 deletions(-) diff --git a/packages/cli/src/commands/composite/create.ts b/packages/cli/src/commands/composite/create.ts index 39eefd584..13a351cc1 100644 --- a/packages/cli/src/commands/composite/create.ts +++ b/packages/cli/src/commands/composite/create.ts @@ -28,7 +28,7 @@ export default class CreateComposite extends Command { static description = 'deploy models included in the composite on connected ceramic node' @@ -21,15 +17,6 @@ export default class CompositeDeploy extends Command< }), } - static flags = { - ...Command.flags, - index: Flags.boolean({ - char: 'i', - description: 'Adds the composite to indexing on the ceramic node', - default: true, - }), - } - async run(): Promise { try { this.spinner.start('Deploying the composite...') @@ -39,10 +26,10 @@ export default class CompositeDeploy extends Command< composite = await Composite.fromJSON({ ceramic: this.ceramic, definition, - index: this.flags.index, + index: true, }) } else if (this.args.compositePath !== undefined) { - composite = await readEncodedComposite(this.ceramic, this.args.compositePath, this.flags.index) + composite = await readEncodedComposite(this.ceramic, this.args.compositePath, true) } else { this.spinner.fail( 'You need to pass the composite definition either in stdin or as the compositePath param', diff --git a/packages/cli/test/composites.test.ts b/packages/cli/test/composites.test.ts index db938edeb..732d05d0a 100644 --- a/packages/cli/test/composites.test.ts +++ b/packages/cli/test/composites.test.ts @@ -154,30 +154,6 @@ describe('composites', () => { expect(doesModelExistNow).toBeTruthy() await expect(checkIfModelIndexed(ceramic, nonExistentModelStreamID)).resolves.toBeTruthy() }, 60000) - - test('composite deployment succeeds but is not indexed when no-index is specified', async () => { - const nonExistentModelStreamID = Object.keys( - (undeployedComposite as EncodedCompositeDefinition).models, - )[0] - const ceramic = new CeramicClient() - // The following check fails in CI as the same tests are running in parallel in different environments - // const doesModelExist = await checkIfModelExist(ceramic, nonExistentModelStreamID) - // expect(doesModelExist).toBeFalsy() - const deploy = await execa('bin/run.js', [ - 'composite:deploy', - 'test/mocks/encoded.composite.undeployed.json', - `--did-private-key=${seed}`, - '--no-index', - ]) - - expect(deploy.stderr.toString().includes(`Deploying the composite... Done!`)).toBe(true) - - expect(deploy.stdout.toString().includes(nonExistentModelStreamID)).toBe(true) - - const doesModelExistNow = await checkIfModelExist(ceramic, nonExistentModelStreamID) - expect(doesModelExistNow).toBeTruthy() - await expect(checkIfModelIndexed(ceramic, nonExistentModelStreamID)).resolves.toBeFalsy() - }, 60000) }) describe('composite:from-model', () => { diff --git a/website/docs/api/commands/cli.composite.md b/website/docs/api/commands/cli.composite.md index cf6d9e093..305705a99 100644 --- a/website/docs/api/commands/cli.composite.md +++ b/website/docs/api/commands/cli.composite.md @@ -46,6 +46,10 @@ Create an encoded composite definition from GraphQL [Composite Schema](https://d You can find a detailed guide on the creation of Composites [here](https://developers.ceramic.network/docs/composedb/guides/data-modeling/composites) +If updating your composite, run this command with `--no-deploy`. Your GraphQL +definition will still be updated, but Ceramic will not attempt to re-index +your composite. + ``` USAGE $ composedb composite:create INPUT @@ -58,6 +62,7 @@ OPTIONS -k, --did-private-key DID Private Key (you can generate a fresh private key using composedb did:generate-private-key) -o, --output a path to file where the resulting encoded composite definition should be saved -d, --deploy Deploy the composite to the ceramic node, which will start indexing on the composite + --no-deploy Do not deploy the composite to the ceramic node ``` ### `composedb composite:models` @@ -118,6 +123,12 @@ available on the Ceramic Node that yor DApp connects to. You can find a detailed guide on Composites' deployment [here](https://developers.ceramic.network/docs/composedb/guides/data-modeling/composites#deploying-composites) +If updating your composite to add additional query fields, do not run this command. +It should only be run _the first time_ you add your composite to the Ceramic node. + +If you are reusing a model multiple times in different composites, you can also +skip this command. + ``` USAGE $ composedb composite:deploy PATH @@ -128,8 +139,6 @@ ARGUMENTS OPTIONS -c, --ceramic-url Ceramic API URL -k, --did-private-key DID Private Key (you can generate a fresh private key using composedb did:generate-private-key) - -i, --index Adds the composite to indexing on the ceramic node (default) - --no-index Prevents the composite from being indexed on the ceramic node. Useful if composite has already been deployed and indexed ``` ### `composedb composite:compile`