diff --git a/package-lock.json b/package-lock.json index 7c45366..196127b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@chelonia/cli", - "version": "2.2.2", + "version": "2.2.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@chelonia/cli", - "version": "2.2.2", + "version": "2.2.3", "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { diff --git a/src/deploy.ts b/src/deploy.ts index 985cb03..5baab4c 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -5,6 +5,10 @@ import { path } from './deps.ts' import { upload } from './upload.ts' +// Prefixes to use to select the correct CID to use +const CONTRACT_TEXT_PREFIX = `t|` +const CONTRACT_MANIFEST_PREFIX = `m|` + export async function deploy (args: string[]) { const [urlOrDirOrSqliteFile, ...manifests] = args if (manifests.length === 0) throw new Error('missing url or manifests!') @@ -13,11 +17,11 @@ export async function deploy (args: string[]) { const json = JSON.parse(Deno.readTextFileSync(manifestPath)) const body = JSON.parse(json.body) const dirname = path.dirname(manifestPath) - toUpload.push('t|' + path.join(dirname, body.contract.file)) + toUpload.push(CONTRACT_TEXT_PREFIX + path.join(dirname, body.contract.file)) if (body.contractSlim) { - toUpload.push('t|' + path.join(dirname, body.contractSlim.file)) + toUpload.push(CONTRACT_TEXT_PREFIX + path.join(dirname, body.contractSlim.file)) } - toUpload.push('m|' + manifestPath) + toUpload.push(CONTRACT_MANIFEST_PREFIX + manifestPath) } await upload([urlOrDirOrSqliteFile, ...toUpload], true) } diff --git a/src/upload.ts b/src/upload.ts index 0721304..e96e3d6 100644 --- a/src/upload.ts +++ b/src/upload.ts @@ -17,7 +17,9 @@ export async function upload (args: string[], internal = false) { for (const filepath_ of files) { let type = multicodes.RAW let filepath = filepath_ - if (filepath_[1] === '|') { + if (internal) { + // The `{type}|` prefix is used to determine which kind of CID is needed + if (filepath_[1] !== '|') throw new Error('Invalid path format') switch (filepath_[0]) { case 'r': // raw file type