build-strap 5.1.0-dev.118 → 5.1.0
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/package.json +1 -1
- package/src/cp.d.ts +0 -1
- package/src/docker.js +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/npm.d.ts +2 -1
- package/src/npm.js +12 -2
- package/src/orbstack.d.ts +3 -0
- package/src/orbstack.js +89 -0
- package/src/tgz.d.ts +3 -4
package/package.json
CHANGED
package/src/cp.d.ts
CHANGED
package/src/docker.js
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/npm.d.ts
CHANGED
|
@@ -32,12 +32,13 @@ export interface NpmPublishOptions {
|
|
|
32
32
|
npmConfig?: NpmConfig;
|
|
33
33
|
npmCreds?: NpmCreds;
|
|
34
34
|
npmPath?: string;
|
|
35
|
+
provenance?: boolean;
|
|
35
36
|
publishPath?: string;
|
|
36
37
|
skipExisting?: boolean;
|
|
37
38
|
tag?: string;
|
|
38
39
|
workDir?: string;
|
|
39
40
|
}
|
|
40
|
-
export declare function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, publishPath, skipExisting, tag, workDir: passedWorkDir, }?: NpmPublishOptions): Promise<boolean>;
|
|
41
|
+
export declare function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, provenance, publishPath, skipExisting, tag, workDir: passedWorkDir, }?: NpmPublishOptions): Promise<boolean>;
|
|
41
42
|
interface NpmPackOptions {
|
|
42
43
|
destination?: string;
|
|
43
44
|
npmConfig?: NpmConfig;
|
package/src/npm.js
CHANGED
|
@@ -48,6 +48,7 @@ export async function npmWriteRc({ authToken, creds, outPath, registry, }) {
|
|
|
48
48
|
// Write out .npmrc with credentials
|
|
49
49
|
const theRegistry = registry || 'https://registry.npmjs.org/';
|
|
50
50
|
const [, host] = /^(?:http(?:s)?:\/\/)?(.+)$/.exec(theRegistry) || [];
|
|
51
|
+
buildLog(`Writing npmrc with registry ${theRegistry}`);
|
|
51
52
|
await fs.mkdirp(path.dirname(outPath));
|
|
52
53
|
await fs.writeFile(outPath, `registry=${theRegistry}
|
|
53
54
|
${authToken ? `//${host}:_authToken=${authToken}` : ''}
|
|
@@ -57,7 +58,7 @@ always-auth=true
|
|
|
57
58
|
email=${creds.email}`
|
|
58
59
|
: ''}`);
|
|
59
60
|
}
|
|
60
|
-
export async function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, publishPath = '.', skipExisting = false, tag, workDir: passedWorkDir, } = {}) {
|
|
61
|
+
export async function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, provenance = false, publishPath = '.', skipExisting = false, tag, workDir: passedWorkDir, } = {}) {
|
|
61
62
|
const creds = npmCreds || envNpmCreds;
|
|
62
63
|
const authToken = npmAuthToken || process.env.NPM_TOKEN;
|
|
63
64
|
const name = getPkgName(true);
|
|
@@ -93,6 +94,9 @@ export async function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, p
|
|
|
93
94
|
}
|
|
94
95
|
throw new Error('Failed to publish npm package, this version already exists!');
|
|
95
96
|
}
|
|
97
|
+
if (authToken) {
|
|
98
|
+
buildLog(`Using NPM_TOKEN for authentication`);
|
|
99
|
+
}
|
|
96
100
|
await npm({
|
|
97
101
|
args: [
|
|
98
102
|
'publish',
|
|
@@ -106,6 +110,7 @@ export async function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, p
|
|
|
106
110
|
: 'branch'),
|
|
107
111
|
...(access ? ['--access', access] : []),
|
|
108
112
|
...(dryRun ? ['--dry-run'] : []),
|
|
113
|
+
...(provenance ? ['--provenance'] : []),
|
|
109
114
|
'--color=always',
|
|
110
115
|
],
|
|
111
116
|
npmPath,
|
|
@@ -113,7 +118,12 @@ export async function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, p
|
|
|
113
118
|
cwd: workDir,
|
|
114
119
|
env: {
|
|
115
120
|
...process.env,
|
|
116
|
-
|
|
121
|
+
npm_config_registry: registry || 'https://registry.npmjs.org/',
|
|
122
|
+
...(authToken
|
|
123
|
+
? {
|
|
124
|
+
NPM_TOKEN: authToken,
|
|
125
|
+
}
|
|
126
|
+
: {}),
|
|
117
127
|
},
|
|
118
128
|
},
|
|
119
129
|
});
|
package/src/orbstack.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { brew } from './brew';
|
|
5
|
+
import { spawn } from './cp';
|
|
6
|
+
import { dockerIsRunning } from './docker';
|
|
7
|
+
import { cmdExists, isMac } from './env';
|
|
8
|
+
import { buildLog } from './run';
|
|
9
|
+
export const ensureOrbStackInstalled = async () => {
|
|
10
|
+
if (!isMac()) {
|
|
11
|
+
throw new Error('OrbStack is only supported on macOS');
|
|
12
|
+
}
|
|
13
|
+
if (!(await cmdExists('orb'))) {
|
|
14
|
+
await brew(['install', 'orbstack']);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const ensureOrbStackRunning = async (timeoutSeconds = 600) => {
|
|
18
|
+
if (!(await dockerIsRunning())) {
|
|
19
|
+
if (!isMac()) {
|
|
20
|
+
throw new Error('OrbStack is only supported on macOS');
|
|
21
|
+
}
|
|
22
|
+
buildLog('docker is not running, starting OrbStack...');
|
|
23
|
+
await spawn('open', ['-a', '/Applications/OrbStack.app']);
|
|
24
|
+
let attempts = 0;
|
|
25
|
+
while (!(await dockerIsRunning())) {
|
|
26
|
+
attempts += 1;
|
|
27
|
+
if (attempts % 5 === 0) {
|
|
28
|
+
process.stdout.write('.');
|
|
29
|
+
}
|
|
30
|
+
if (attempts > timeoutSeconds) {
|
|
31
|
+
throw new Error('Timeout starting OrbStack');
|
|
32
|
+
}
|
|
33
|
+
await new Promise((resolve) => {
|
|
34
|
+
setTimeout(resolve, 1000);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (attempts >= 5) {
|
|
38
|
+
process.stdout.write('\n');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const defaultConfig = {
|
|
43
|
+
memory_mib: 16384,
|
|
44
|
+
};
|
|
45
|
+
export const ensureOrbStackConfigured = async (desiredConfig) => {
|
|
46
|
+
if (!desiredConfig) {
|
|
47
|
+
buildLog('Skipping OrbStack configuration due to empty config value');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!isMac()) {
|
|
51
|
+
throw new Error('OrbStack is only supported on macOS');
|
|
52
|
+
}
|
|
53
|
+
const configPath = path.join(os.homedir(), '.orbstack/vmconfig.json');
|
|
54
|
+
await fs.ensureDir(path.dirname(configPath));
|
|
55
|
+
let changed = false;
|
|
56
|
+
if (!(await fs.pathExists(configPath))) {
|
|
57
|
+
buildLog('Setting OrbStack config...');
|
|
58
|
+
await fs.writeJson(configPath, desiredConfig, { spaces: 2 });
|
|
59
|
+
changed = true;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const existingConfig = await fs.readJson(configPath);
|
|
63
|
+
const effectiveConfig = {
|
|
64
|
+
...defaultConfig,
|
|
65
|
+
...existingConfig,
|
|
66
|
+
};
|
|
67
|
+
if (!Object.entries(desiredConfig).every(([key, value]) => effectiveConfig[key] === value)) {
|
|
68
|
+
buildLog('Adjusting OrbStack config...');
|
|
69
|
+
const newConfig = {
|
|
70
|
+
...existingConfig,
|
|
71
|
+
...desiredConfig,
|
|
72
|
+
};
|
|
73
|
+
for (const [key, value] of Object.entries(defaultConfig)) {
|
|
74
|
+
if (newConfig[key] === value) {
|
|
75
|
+
// Don't write default values
|
|
76
|
+
delete newConfig[key];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
await fs.writeJson(configPath, newConfig, { spaces: 2 });
|
|
80
|
+
changed = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (changed && (await dockerIsRunning())) {
|
|
84
|
+
// Restart the app
|
|
85
|
+
buildLog('Killing OrbStack...');
|
|
86
|
+
await spawn('osascript', ['-e', `quit app "OrbStack"`]);
|
|
87
|
+
await ensureOrbStackRunning();
|
|
88
|
+
}
|
|
89
|
+
};
|
package/src/tgz.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Readable } from 'stream';
|
|
3
|
-
import {
|
|
2
|
+
import { TarOptionsWithAliasesNoFile } from 'tar/dist/commonjs/options.js';
|
|
4
3
|
export type ArtifactInfo = {
|
|
5
4
|
contentType?: string;
|
|
6
5
|
md5: string;
|
|
@@ -8,6 +7,6 @@ export type ArtifactInfo = {
|
|
|
8
7
|
sha512: string;
|
|
9
8
|
size: number;
|
|
10
9
|
};
|
|
11
|
-
export declare const generateFileHash: (filePath: string, type:
|
|
10
|
+
export declare const generateFileHash: (filePath: string, type: "md5" | "sha1" | "sha512") => Promise<string>;
|
|
12
11
|
export declare function getArtifactInfo(artifact: string | Pick<Readable, 'pipe'>): Promise<ArtifactInfo>;
|
|
13
|
-
export declare function tgzDir(srcDir: string, outPath: string, options?:
|
|
12
|
+
export declare function tgzDir(srcDir: string, outPath: string, options?: TarOptionsWithAliasesNoFile): Promise<ArtifactInfo>;
|