@tahminator/pipeline 1.0.11 → 1.0.13
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/dist/internal/upload-npm/index.js +13 -1
- package/dist/npm/client.d.ts +5 -2
- package/dist/npm/client.js +17 -7
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import yargs from "yargs";
|
|
2
2
|
import { hideBin } from "yargs/helpers";
|
|
3
3
|
import { NPMClient } from "../../npm";
|
|
4
|
+
import { Utils } from "../../utils";
|
|
4
5
|
const { dryRun } = await yargs(hideBin(process.argv))
|
|
5
6
|
.option("dryRun", {
|
|
6
7
|
type: "boolean",
|
|
@@ -9,9 +10,20 @@ const { dryRun } = await yargs(hideBin(process.argv))
|
|
|
9
10
|
.strict()
|
|
10
11
|
.parse();
|
|
11
12
|
async function main() {
|
|
12
|
-
|
|
13
|
+
const { npmToken } = parseCiEnv(await Utils.getEnvVariables(["ci"]));
|
|
14
|
+
await using npmClient = await NPMClient.create(npmToken);
|
|
13
15
|
await npmClient.publish(dryRun);
|
|
14
16
|
}
|
|
17
|
+
function parseCiEnv(ciEnv) {
|
|
18
|
+
const npmToken = (() => {
|
|
19
|
+
const v = ciEnv["NPM_TOKEN"];
|
|
20
|
+
if (!v) {
|
|
21
|
+
throw new Error("Missing NPM_TOKEN from .env.ci");
|
|
22
|
+
}
|
|
23
|
+
return v;
|
|
24
|
+
})();
|
|
25
|
+
return { npmToken };
|
|
26
|
+
}
|
|
15
27
|
main()
|
|
16
28
|
.then(() => {
|
|
17
29
|
process.exit(0);
|
package/dist/npm/client.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export declare class NPMClient {
|
|
2
|
+
private readonly npmToken?;
|
|
2
3
|
private constructor();
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Create NPMClient using an `npmToken` if passed in or OIDC / [Trusted Publishing](https://docs.npmjs.com/trusted-publishers).
|
|
6
|
+
*
|
|
7
|
+
* __It is recommended that you use [Trusted Publishing](https://docs.npmjs.com/trusted-publishers) now.__ Using tokens
|
|
5
8
|
* now are extremely flaky and should be avoided.
|
|
6
9
|
*
|
|
7
10
|
* __NOTE: Base yaml must have this property__
|
|
@@ -12,7 +15,7 @@ export declare class NPMClient {
|
|
|
12
15
|
* id-token: write # Required for OIDC
|
|
13
16
|
* ```
|
|
14
17
|
*/
|
|
15
|
-
static create(): Promise<NPMClient>;
|
|
18
|
+
static create(npmToken?: string): Promise<NPMClient>;
|
|
16
19
|
/**
|
|
17
20
|
* @note You must ensure that the current root directory `package.json`
|
|
18
21
|
* is filled out with the name of the package and the version you would like to
|
package/dist/npm/client.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { $ } from "bun";
|
|
2
2
|
import { Utils } from "../utils";
|
|
3
3
|
export class NPMClient {
|
|
4
|
-
|
|
4
|
+
npmToken;
|
|
5
|
+
constructor(npmToken) {
|
|
6
|
+
this.npmToken = npmToken;
|
|
7
|
+
}
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
9
|
+
* Create NPMClient using an `npmToken` if passed in or OIDC / [Trusted Publishing](https://docs.npmjs.com/trusted-publishers).
|
|
10
|
+
*
|
|
11
|
+
* __It is recommended that you use [Trusted Publishing](https://docs.npmjs.com/trusted-publishers) now.__ Using tokens
|
|
7
12
|
* now are extremely flaky and should be avoided.
|
|
8
13
|
*
|
|
9
14
|
* __NOTE: Base yaml must have this property__
|
|
@@ -14,9 +19,11 @@ export class NPMClient {
|
|
|
14
19
|
* id-token: write # Required for OIDC
|
|
15
20
|
* ```
|
|
16
21
|
*/
|
|
17
|
-
static async create() {
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
static async create(npmToken) {
|
|
23
|
+
if (npmToken) {
|
|
24
|
+
await $ `npm config set //registry.npmjs.org/:_authToken=${npmToken}`;
|
|
25
|
+
}
|
|
26
|
+
return new this(npmToken);
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* @note You must ensure that the current root directory `package.json`
|
|
@@ -31,13 +38,16 @@ export class NPMClient {
|
|
|
31
38
|
console.log(await $ `pwd`.text());
|
|
32
39
|
console.log(await $ `cat ./package.json`.text());
|
|
33
40
|
}
|
|
34
|
-
|
|
41
|
+
const provenanceFlag = this.npmToken ? [] : ["--provenance"];
|
|
42
|
+
await $ `npm publish --access public ${provenanceFlag} ${dryRunFlag} ./`;
|
|
35
43
|
console.log("Package has been successfully published");
|
|
36
44
|
}
|
|
37
45
|
async [Symbol.asyncDispose]() {
|
|
38
46
|
await this.cleanup();
|
|
39
47
|
}
|
|
40
48
|
async cleanup() {
|
|
41
|
-
|
|
49
|
+
if (this.npmToken) {
|
|
50
|
+
await $ `npm logout`;
|
|
51
|
+
}
|
|
42
52
|
}
|
|
43
53
|
}
|
package/package.json
CHANGED