Skip to content

Commit

Permalink
fix: create deploys by default, no index flag for deploy, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dbcfd committed Nov 30, 2023
1 parent a8aeefb commit 71292dd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 44 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/composite/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class CreateComposite extends Command<Flags, { schemaFilePath: st
char: 'd',
description:
'Deploy the composite to the ceramic node, which will start indexing on the composite',
default: false,
default: true,
}),
}

Expand Down
21 changes: 4 additions & 17 deletions packages/cli/src/commands/composite/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { Command, type CommandFlags } from '../../command.js'
import { Args, Flags } from '@oclif/core'
import { Args } from '@oclif/core'
import { readEncodedComposite } from '@composedb/devtools-node'
import { Composite } from '@composedb/devtools'
import { EncodedCompositeDefinition } from '@composedb/types'

type Flags = CommandFlags & {
index: boolean
}

export default class CompositeDeploy extends Command<
Flags,
CommandFlags,
{ compositePath: string | undefined }
> {
static description = 'deploy models included in the composite on connected ceramic node'
Expand All @@ -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<void> {
try {
this.spinner.start('Deploying the composite...')
Expand All @@ -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',
Expand Down
24 changes: 0 additions & 24 deletions packages/cli/test/composites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
13 changes: 11 additions & 2 deletions website/docs/api/commands/cli.composite.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand Down Expand Up @@ -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
Expand All @@ -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`
Expand Down

0 comments on commit 71292dd

Please sign in to comment.