@arc-e-tect/api-only-publisher 0.14.3 → 0.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.adoc +1 -1
- package/package.json +1 -1
- package/src/pack.js +17 -2
package/README.adoc
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
:source-highlighter: rouge
|
|
7
7
|
// The released version of this component: its snippets use it. The release
|
|
8
8
|
// workflow updates it; do not change it by hand.
|
|
9
|
-
:api-only-publisher-version: 0.14.
|
|
9
|
+
:api-only-publisher-version: 0.14.4
|
|
10
10
|
|
|
11
11
|
[NOTE]
|
|
12
12
|
.About this documentation
|
package/package.json
CHANGED
package/src/pack.js
CHANGED
|
@@ -22,6 +22,21 @@ function sha256(file) {
|
|
|
22
22
|
return crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* A repository URL fit to publish: without the credentials a remote URL can carry --
|
|
27
|
+
* GitLab CI checks out with `https://gitlab-ci-token:<job token>@host/...`, and a
|
|
28
|
+
* clone made with a token in its URL keeps it there -- and without a query string or
|
|
29
|
+
* fragment, where some hosts carry one too. An scp-like `git@host:path` and a local
|
|
30
|
+
* path are left alone: neither holds a secret.
|
|
31
|
+
*/
|
|
32
|
+
function publicUrl(url) {
|
|
33
|
+
if (!url) return url;
|
|
34
|
+
const match = /^([a-z][a-z0-9+.-]*:\/\/)([^/?#]*)([^?#]*)/i.exec(url);
|
|
35
|
+
if (!match) return url;
|
|
36
|
+
const [, scheme, authority, rest] = match;
|
|
37
|
+
return scheme + authority.slice(authority.lastIndexOf("@") + 1) + rest;
|
|
38
|
+
}
|
|
39
|
+
|
|
25
40
|
function gitInfo(cwd) {
|
|
26
41
|
const git = (args) => {
|
|
27
42
|
try {
|
|
@@ -31,7 +46,7 @@ function gitInfo(cwd) {
|
|
|
31
46
|
}
|
|
32
47
|
};
|
|
33
48
|
return {
|
|
34
|
-
repository: git(["config", "--get", "remote.origin.url"]),
|
|
49
|
+
repository: publicUrl(git(["config", "--get", "remote.origin.url"])),
|
|
35
50
|
commit: git(["rev-parse", "HEAD"]),
|
|
36
51
|
};
|
|
37
52
|
}
|
|
@@ -145,4 +160,4 @@ function pack(config, target, { version, closureSha256, outDir, log = () => {} }
|
|
|
145
160
|
return { archive, manifest: data, manifestPath };
|
|
146
161
|
}
|
|
147
162
|
|
|
148
|
-
module.exports = { pack, manifest, sha256, MANIFEST_NAME, MANIFEST_SCHEMA_VERSION, PackError };
|
|
163
|
+
module.exports = { pack, manifest, sha256, MANIFEST_NAME, MANIFEST_SCHEMA_VERSION, PackError, publicUrl };
|