diff --git a/bin/cml/comment/create.js b/bin/cml/comment/create.js index ff6bb15fe..59ea2a60d 100644 --- a/bin/cml/comment/create.js +++ b/bin/cml/comment/create.js @@ -26,6 +26,11 @@ exports.options = kebabcaseKeys({ type: 'boolean', description: 'Upload any local images found in the Markdown report' }, + publishUrl: { + type: 'string', + default: 'https://asset.cml.dev', + description: 'Self-hosted image server URL' + }, watch: { type: 'boolean', description: 'Watch for changes and automatically update the comment' diff --git a/bin/cml/comment/create.test.js b/bin/cml/comment/create.test.js index 8ed29a39a..feb06e944 100644 --- a/bin/cml/comment/create.test.js +++ b/bin/cml/comment/create.test.js @@ -33,6 +33,8 @@ describe('Comment integration tests', () => { [string] [default: \\"HEAD\\"] --publish Upload any local images found in the Markdown report [boolean] + --publish-url Self-hosted image server URL + [string] [default: \\"https://asset.cml.dev\\"] --watch Watch for changes and automatically update the comment [boolean] --native Uses driver's native capabilities to upload assets @@ -64,4 +66,11 @@ describe('Comment integration tests', () => { await fs.writeFile(path, report); await exec(`node ./bin/cml.js send-comment ${path}`); }); + + test('cml send-comment --publish to current repo', async () => { + const report = `## Test Comment\n![](assets/logo.png)`; + + await fs.writeFile(path, report); + await exec(`node ./bin/cml.js send-comment --publish ${path}`); + }); }); diff --git a/package-lock.json b/package-lock.json index 5e46aa034..4c45035e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "form-data": "^3.0.1", "fs-extra": "^9.1.0", "getos": "^3.2.1", - "git-url-parse": "^12.0.0", + "git-url-parse": "^13.1.0", "globby": "^11.0.4", "https-proxy-agent": "^5.0.1", "js-base64": "^3.7.2", @@ -3429,18 +3429,20 @@ } }, "node_modules/git-up": { - "version": "6.0.0", - "license": "MIT", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz", + "integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==", "dependencies": { "is-ssh": "^1.4.0", - "parse-url": "^7.0.2" + "parse-url": "^8.1.0" } }, "node_modules/git-url-parse": { - "version": "12.0.0", - "license": "MIT", + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-13.1.0.tgz", + "integrity": "sha512-5FvPJP/70WkIprlUZ33bm4UAaFdjcLkJLpWft1BeZKqwR0uhhNGoKwlUaPtVb4LxCSQ++erHapRak9kWGj+FCA==", "dependencies": { - "git-up": "^6.0.0" + "git-up": "^7.0.0" } }, "node_modules/glob": { @@ -4111,7 +4113,8 @@ }, "node_modules/is-ssh": { "version": "1.4.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", + "integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==", "dependencies": { "protocols": "^2.0.1" } @@ -5538,16 +5541,6 @@ "node": ">=0.10.0" } }, - "node_modules/normalize-url": { - "version": "6.1.0", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/npm-run-path": { "version": "4.0.1", "license": "MIT", @@ -5797,20 +5790,19 @@ } }, "node_modules/parse-path": { - "version": "5.0.0", - "license": "MIT", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz", + "integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==", "dependencies": { "protocols": "^2.0.0" } }, "node_modules/parse-url": { - "version": "7.0.2", - "license": "MIT", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz", + "integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==", "dependencies": { - "is-ssh": "^1.4.0", - "normalize-url": "^6.1.0", - "parse-path": "^5.0.0", - "protocols": "^2.0.1" + "parse-path": "^7.0.0" } }, "node_modules/parse5": { @@ -6031,7 +6023,8 @@ }, "node_modules/protocols": { "version": "2.0.1", - "license": "MIT" + "resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz", + "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==" }, "node_modules/proxy-agent": { "version": "5.0.0", @@ -9835,16 +9828,20 @@ } }, "git-up": { - "version": "6.0.0", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz", + "integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==", "requires": { "is-ssh": "^1.4.0", - "parse-url": "^7.0.2" + "parse-url": "^8.1.0" } }, "git-url-parse": { - "version": "12.0.0", + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-13.1.0.tgz", + "integrity": "sha512-5FvPJP/70WkIprlUZ33bm4UAaFdjcLkJLpWft1BeZKqwR0uhhNGoKwlUaPtVb4LxCSQ++erHapRak9kWGj+FCA==", "requires": { - "git-up": "^6.0.0" + "git-up": "^7.0.0" } }, "glob": { @@ -10214,6 +10211,8 @@ }, "is-ssh": { "version": "1.4.0", + "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", + "integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==", "requires": { "protocols": "^2.0.1" } @@ -11171,9 +11170,6 @@ "normalize-path": { "version": "3.0.0" }, - "normalize-url": { - "version": "6.1.0" - }, "npm-run-path": { "version": "4.0.1", "requires": { @@ -11330,18 +11326,19 @@ } }, "parse-path": { - "version": "5.0.0", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz", + "integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==", "requires": { "protocols": "^2.0.0" } }, "parse-url": { - "version": "7.0.2", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz", + "integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==", "requires": { - "is-ssh": "^1.4.0", - "normalize-url": "^6.1.0", - "parse-path": "^5.0.0", - "protocols": "^2.0.1" + "parse-path": "^7.0.0" } }, "parse5": { @@ -11465,7 +11462,9 @@ } }, "protocols": { - "version": "2.0.1" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz", + "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==" }, "proxy-agent": { "version": "5.0.0", diff --git a/package.json b/package.json index d529ba5a2..f1a2afa4b 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "form-data": "^3.0.1", "fs-extra": "^9.1.0", "getos": "^3.2.1", - "git-url-parse": "^12.0.0", + "git-url-parse": "^13.1.0", "globby": "^11.0.4", "https-proxy-agent": "^5.0.1", "js-base64": "^3.7.2", diff --git a/src/cml.js b/src/cml.js index 505c1d749..8a755e26b 100755 --- a/src/cml.js +++ b/src/cml.js @@ -167,6 +167,7 @@ class CML { update, pr, publish, + publishUrl, markdownFile, report: testReport, watch, @@ -208,7 +209,11 @@ class CML { ); if (!triggerFile && watch) watcher.add(absolutePath); try { - node.url = await this.publish({ ...opts, path: absolutePath }); + node.url = await this.publish({ + ...opts, + path: absolutePath, + url: publishUrl + }); } catch (err) { if (err.code !== 'ENOENT') throw err; }