build-strap 4.0.0-dev.3 → 4.0.0-dev.52
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/npm.d.ts +7 -1
- package/npm.js +60 -33
- package/package.json +1 -1
- package/yarn.d.ts +1 -1
- package/yarn.js +9 -15
package/npm.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SpawnOptions, SpawnResult } from './cp.js';
|
|
1
2
|
export declare type NpmCreds = {
|
|
2
3
|
email?: string;
|
|
3
4
|
password?: string;
|
|
@@ -12,7 +13,12 @@ export declare type NpmConfig = {
|
|
|
12
13
|
};
|
|
13
14
|
export declare function getNpmConfig(): NpmConfig;
|
|
14
15
|
export declare const envNpmCreds: null | NpmCreds;
|
|
15
|
-
export
|
|
16
|
+
export interface NpmOptions {
|
|
17
|
+
args?: string[];
|
|
18
|
+
npmPath?: string;
|
|
19
|
+
spawnOptions?: SpawnOptions;
|
|
20
|
+
}
|
|
21
|
+
export declare function npm({ args, spawnOptions, npmPath, }?: NpmOptions): Promise<SpawnResult>;
|
|
16
22
|
export declare function npmGetVersions(packageName: string, npmPath?: string): Promise<string[]>;
|
|
17
23
|
interface NpmWriteRcOptions {
|
|
18
24
|
authToken?: string;
|
package/npm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import { platform } from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import {
|
|
4
|
+
import { spawn } from './cp.js';
|
|
5
5
|
import { getCfg, getPkgName } from './pkg.js';
|
|
6
6
|
import { buildLog } from './run.js';
|
|
7
7
|
import { getDevBranch, getVersion } from './version.js';
|
|
@@ -10,12 +10,32 @@ export function getNpmConfig() {
|
|
|
10
10
|
}
|
|
11
11
|
export const envNpmCreds = (process.env.NPM_CREDS && JSON.parse(process.env.NPM_CREDS)) || null;
|
|
12
12
|
const npmExe = (npmPath) => npmPath || (platform() === 'win32' ? 'npm.cmd' : 'npm');
|
|
13
|
-
export async function
|
|
14
|
-
|
|
13
|
+
export async function npm({ args = [], spawnOptions, npmPath, } = {}) {
|
|
14
|
+
const localNpm = path.join(path.dirname(process.execPath), 'lib/node_modules/npm/bin/npm-cli.js');
|
|
15
|
+
const spawnOpts = {
|
|
16
|
+
env: process.env,
|
|
17
|
+
shell: true,
|
|
18
|
+
stdio: 'inherit',
|
|
19
|
+
...spawnOptions,
|
|
20
|
+
};
|
|
21
|
+
return npmPath
|
|
22
|
+
? spawn(npmPath, args, spawnOpts)
|
|
23
|
+
: (await fs.pathExists(localNpm))
|
|
24
|
+
? // prefer to use local copy of npm
|
|
25
|
+
spawn(process.execPath, [localNpm, ...args], spawnOpts)
|
|
26
|
+
: // fall back to globally installed npm
|
|
27
|
+
spawn(npmExe(), args, spawnOpts);
|
|
15
28
|
}
|
|
16
29
|
export async function npmGetVersions(packageName, npmPath) {
|
|
17
30
|
try {
|
|
18
|
-
return JSON.parse((await
|
|
31
|
+
return JSON.parse((await npm({
|
|
32
|
+
args: ['show', packageName, 'versions', '--json'],
|
|
33
|
+
npmPath,
|
|
34
|
+
spawnOptions: {
|
|
35
|
+
captureOutput: true,
|
|
36
|
+
stdio: 'pipe',
|
|
37
|
+
},
|
|
38
|
+
})).stdout.trim());
|
|
19
39
|
}
|
|
20
40
|
catch (err) {
|
|
21
41
|
buildLog(`warning: failed to find existing package for ${packageName} in npm registry: ${err.message}`);
|
|
@@ -71,27 +91,29 @@ export async function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, p
|
|
|
71
91
|
}
|
|
72
92
|
throw new Error('Failed to publish npm package, this version already exists!');
|
|
73
93
|
}
|
|
74
|
-
await
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
await npm({
|
|
95
|
+
args: [
|
|
96
|
+
'publish',
|
|
97
|
+
resolvedPath,
|
|
98
|
+
'--tag',
|
|
99
|
+
tag ||
|
|
100
|
+
(isRelease
|
|
101
|
+
? 'latest'
|
|
102
|
+
: branch === (await getDevBranch())
|
|
103
|
+
? 'next'
|
|
104
|
+
: 'branch'),
|
|
105
|
+
...(access ? ['--access', access] : []),
|
|
106
|
+
...(dryRun ? ['--dry-run'] : []),
|
|
107
|
+
'--color=always',
|
|
108
|
+
],
|
|
109
|
+
npmPath,
|
|
110
|
+
spawnOptions: {
|
|
111
|
+
cwd: workDir,
|
|
112
|
+
env: {
|
|
113
|
+
...process.env,
|
|
114
|
+
NPM_TOKEN: authToken,
|
|
115
|
+
},
|
|
92
116
|
},
|
|
93
|
-
shell: true,
|
|
94
|
-
stdio: 'inherit',
|
|
95
117
|
});
|
|
96
118
|
return true;
|
|
97
119
|
}
|
|
@@ -100,15 +122,20 @@ export async function npmPack({ destination, npmConfig, npmPath, workDir = '.',
|
|
|
100
122
|
if (destination) {
|
|
101
123
|
await fs.ensureDir(destination);
|
|
102
124
|
}
|
|
103
|
-
const { stdout } = await
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
125
|
+
const { stdout } = await npm({
|
|
126
|
+
args: [
|
|
127
|
+
'pack',
|
|
128
|
+
...(dryRun ? ['--dry-run'] : []),
|
|
129
|
+
...(destination ? ['--pack-destination', path.resolve(destination)] : []),
|
|
130
|
+
'--color=always',
|
|
131
|
+
],
|
|
132
|
+
npmPath,
|
|
133
|
+
spawnOptions: {
|
|
134
|
+
captureOutput: true,
|
|
135
|
+
cwd: path.resolve(workDir),
|
|
136
|
+
pipeOutput: true,
|
|
137
|
+
stdio: 'pipe',
|
|
138
|
+
},
|
|
112
139
|
});
|
|
113
140
|
return path.resolve(destination || '.', stdout.trim());
|
|
114
141
|
}
|
package/package.json
CHANGED
package/yarn.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface YarnPublishOptions {
|
|
|
37
37
|
}
|
|
38
38
|
export declare function yarnPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, publishPath, skipExisting, tag, workDir: passedWorkDir, }?: YarnPublishOptions): Promise<boolean>;
|
|
39
39
|
interface YarnPackOptions {
|
|
40
|
-
destination
|
|
40
|
+
destination: string;
|
|
41
41
|
workDir?: string;
|
|
42
42
|
}
|
|
43
43
|
export declare function yarnPack({ destination, workDir, }: YarnPackOptions): Promise<string>;
|
package/yarn.js
CHANGED
|
@@ -115,6 +115,8 @@ export async function yarnPublish({ npmAuthToken, npmConfig, npmCreds, npmPath,
|
|
|
115
115
|
args: [
|
|
116
116
|
'publish',
|
|
117
117
|
resolvedPath,
|
|
118
|
+
'--new-version',
|
|
119
|
+
npmVersion,
|
|
118
120
|
'--tag',
|
|
119
121
|
tag ||
|
|
120
122
|
(isRelease
|
|
@@ -138,24 +140,16 @@ export async function yarnPublish({ npmAuthToken, npmConfig, npmCreds, npmPath,
|
|
|
138
140
|
return true;
|
|
139
141
|
}
|
|
140
142
|
export async function yarnPack({ destination, workDir = '.', }) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
...(destination ? ['--filename', path.resolve(destination)] : []),
|
|
148
|
-
],
|
|
143
|
+
await fs.ensureDir(destination);
|
|
144
|
+
const version = await getVersion();
|
|
145
|
+
const name = getPkgName();
|
|
146
|
+
const filename = path.resolve(destination, `${name}-${version.npm}.tgz`);
|
|
147
|
+
await yarn({
|
|
148
|
+
args: ['pack', ...(destination ? ['--filename', filename] : [])],
|
|
149
149
|
spawnOptions: {
|
|
150
|
-
captureOutput: true,
|
|
151
150
|
cwd: path.resolve(workDir),
|
|
152
|
-
env: {
|
|
153
|
-
...process.env,
|
|
154
|
-
FORCE_COLOR: 'true',
|
|
155
|
-
},
|
|
156
151
|
pipeOutput: true,
|
|
157
152
|
},
|
|
158
153
|
});
|
|
159
|
-
|
|
160
|
-
return path.resolve(destination || '.', stdout.trim());
|
|
154
|
+
return filename;
|
|
161
155
|
}
|