@atlaspack/package-manager 2.14.5-canary.16 → 2.14.5-canary.160
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/CHANGELOG.md +228 -0
- package/lib/JSONParseStream.js +52 -0
- package/lib/MockPackageInstaller.js +79 -0
- package/lib/NodePackageManager.js +602 -0
- package/lib/Npm.js +106 -0
- package/lib/Pnpm.js +185 -0
- package/lib/Yarn.js +160 -0
- package/lib/getCurrentPackageManager.js +20 -0
- package/lib/index.js +64 -5211
- package/lib/installPackage.js +223 -0
- package/lib/nodejsConditions.js +41 -0
- package/lib/promiseFromProcess.js +20 -0
- package/lib/types/JSONParseStream.d.ts +6 -0
- package/lib/types/MockPackageInstaller.d.ts +14 -0
- package/lib/types/NodePackageManager.d.ts +36 -0
- package/lib/types/Npm.d.ts +4 -0
- package/lib/types/Pnpm.d.ts +5 -0
- package/lib/types/Yarn.d.ts +5 -0
- package/lib/types/getCurrentPackageManager.d.ts +4 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/installPackage.d.ts +5 -0
- package/lib/types/nodejsConditions.d.ts +3 -0
- package/lib/types/promiseFromProcess.d.ts +2 -0
- package/lib/types/utils.d.ts +15 -0
- package/lib/types/validateModuleSpecifier.d.ts +1 -0
- package/lib/utils.js +101 -0
- package/lib/validateModuleSpecifier.js +14 -0
- package/package.json +17 -19
- package/src/{JSONParseStream.js → JSONParseStream.ts} +8 -7
- package/src/{MockPackageInstaller.js → MockPackageInstaller.ts} +4 -6
- package/src/{NodePackageManager.js → NodePackageManager.ts} +88 -57
- package/src/{Npm.js → Npm.ts} +9 -9
- package/src/{Pnpm.js → Pnpm.ts} +68 -50
- package/src/{Yarn.js → Yarn.ts} +38 -25
- package/src/{getCurrentPackageManager.js → getCurrentPackageManager.ts} +9 -4
- package/src/{index.js → index.ts} +0 -2
- package/src/{installPackage.js → installPackage.ts} +5 -6
- package/src/{nodejsConditions.js → nodejsConditions.ts} +6 -3
- package/src/promiseFromProcess.ts +23 -0
- package/src/{utils.js → utils.ts} +21 -11
- package/src/{validateModuleSpecifier.js → validateModuleSpecifier.ts} +0 -2
- package/test/{NodePackageManager.test.js → NodePackageManager.test.ts} +19 -16
- package/test/{getCurrentPackageManager.test.js → getCurrentPackageManager.test.ts} +0 -1
- package/test/{validateModuleSpecifiers.test.js → validateModuleSpecifiers.test.ts} +2 -3
- package/tsconfig.json +4 -0
- package/index.d.ts +0 -40
- package/lib/index.d.ts +0 -10
- package/lib/index.js.map +0 -1
- package/src/promiseFromProcess.js +0 -19
package/src/{Yarn.js → Yarn.ts}
RENAMED
@@ -1,41 +1,49 @@
|
|
1
|
-
// @flow strict-local
|
2
|
-
|
3
1
|
import type {PackageInstaller, InstallerOptions} from '@atlaspack/types';
|
4
2
|
|
3
|
+
// @ts-expect-error TS7016
|
5
4
|
import commandExists from 'command-exists';
|
5
|
+
// @ts-expect-error TS7016
|
6
6
|
import spawn from 'cross-spawn';
|
7
7
|
import {registerSerializableClass} from '@atlaspack/build-cache';
|
8
8
|
import logger from '@atlaspack/logger';
|
9
|
+
// @ts-expect-error TS7016
|
9
10
|
import split from 'split2';
|
10
11
|
import JSONParseStream from './JSONParseStream';
|
11
12
|
import promiseFromProcess from './promiseFromProcess';
|
12
13
|
import {exec, npmSpecifierFromModuleRequest} from './utils';
|
13
14
|
|
14
|
-
// $FlowFixMe
|
15
15
|
import pkg from '../package.json';
|
16
16
|
|
17
17
|
const YARN_CMD = 'yarn';
|
18
18
|
|
19
19
|
type YarnStdOutMessage =
|
20
|
-
| {
|
21
|
-
|
22
|
-
data: {
|
23
|
-
message: string
|
24
|
-
current: number
|
25
|
-
total: number
|
26
|
-
|
27
|
-
|
28
|
-
| {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
20
|
+
| {
|
21
|
+
readonly type: 'step';
|
22
|
+
data: {
|
23
|
+
message: string;
|
24
|
+
current: number;
|
25
|
+
total: number;
|
26
|
+
};
|
27
|
+
}
|
28
|
+
| {
|
29
|
+
readonly type: 'success';
|
30
|
+
data: string;
|
31
|
+
}
|
32
|
+
| {
|
33
|
+
readonly type: 'info';
|
34
|
+
data: string;
|
35
|
+
}
|
36
|
+
| {
|
37
|
+
readonly type: 'tree' | 'progressStart' | 'progressTick';
|
38
|
+
};
|
39
|
+
|
40
|
+
type YarnStdErrMessage = {
|
41
|
+
readonly type: 'error' | 'warning';
|
42
|
+
data: string;
|
43
|
+
};
|
44
|
+
|
45
|
+
let hasYarn: boolean | null | undefined;
|
46
|
+
let yarnVersion: number | null | undefined;
|
39
47
|
|
40
48
|
export class Yarn implements PackageInstaller {
|
41
49
|
static async exists(): Promise<boolean> {
|
@@ -45,7 +53,7 @@ export class Yarn implements PackageInstaller {
|
|
45
53
|
|
46
54
|
try {
|
47
55
|
hasYarn = Boolean(await commandExists('yarn'));
|
48
|
-
} catch (err) {
|
56
|
+
} catch (err: any) {
|
49
57
|
hasYarn = false;
|
50
58
|
}
|
51
59
|
|
@@ -59,6 +67,7 @@ export class Yarn implements PackageInstaller {
|
|
59
67
|
}: InstallerOptions): Promise<void> {
|
60
68
|
if (yarnVersion == null) {
|
61
69
|
let version = await exec('yarn --version');
|
70
|
+
// @ts-expect-error TS2345
|
62
71
|
yarnVersion = parseInt(version.stdout, 10);
|
63
72
|
}
|
64
73
|
|
@@ -76,7 +85,7 @@ export class Yarn implements PackageInstaller {
|
|
76
85
|
// When Parcel is run by Yarn (e.g. via package.json scripts), several environment variables are
|
77
86
|
// added. When parcel in turn calls Yarn again, these can cause Yarn to behave stragely, so we
|
78
87
|
// filter them out when installing packages.
|
79
|
-
let env = {};
|
88
|
+
let env: Record<string, any> = {};
|
80
89
|
for (let key in process.env) {
|
81
90
|
if (
|
82
91
|
!key.startsWith('npm_') &&
|
@@ -92,7 +101,9 @@ export class Yarn implements PackageInstaller {
|
|
92
101
|
installProcess.stdout
|
93
102
|
// Invoking yarn with --json provides streaming, newline-delimited JSON output.
|
94
103
|
.pipe(split())
|
104
|
+
// @ts-expect-error TS2554
|
95
105
|
.pipe(new JSONParseStream())
|
106
|
+
// @ts-expect-error TS7006
|
96
107
|
.on('error', (e) => {
|
97
108
|
logger.error(e, '@atlaspack/package-manager');
|
98
109
|
})
|
@@ -119,7 +130,9 @@ export class Yarn implements PackageInstaller {
|
|
119
130
|
|
120
131
|
installProcess.stderr
|
121
132
|
.pipe(split())
|
133
|
+
// @ts-expect-error TS2554
|
122
134
|
.pipe(new JSONParseStream())
|
135
|
+
// @ts-expect-error TS7006
|
123
136
|
.on('error', (e) => {
|
124
137
|
logger.error(e, '@atlaspack/package-manager');
|
125
138
|
})
|
@@ -144,7 +157,7 @@ export class Yarn implements PackageInstaller {
|
|
144
157
|
|
145
158
|
try {
|
146
159
|
return await promiseFromProcess(installProcess);
|
147
|
-
} catch (e) {
|
160
|
+
} catch (e: any) {
|
148
161
|
throw new Error('Yarn failed to install modules:' + e.message);
|
149
162
|
}
|
150
163
|
}
|
@@ -1,8 +1,13 @@
|
|
1
|
-
// @flow
|
2
|
-
|
3
1
|
export default function getCurrentPackageManager(
|
4
|
-
|
5
|
-
|
2
|
+
// @ts-expect-error TS2322
|
3
|
+
userAgent: string | null = process.env.npm_config_user_agent,
|
4
|
+
):
|
5
|
+
| {
|
6
|
+
name: string;
|
7
|
+
version: string;
|
8
|
+
}
|
9
|
+
| null
|
10
|
+
| undefined {
|
6
11
|
if (!userAgent) {
|
7
12
|
return undefined;
|
8
13
|
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
// @flow
|
2
|
-
|
3
1
|
import type {FilePath, PackageJSON} from '@atlaspack/types';
|
4
2
|
import type {
|
5
3
|
ModuleRequest,
|
@@ -62,7 +60,7 @@ async function install(
|
|
62
60
|
packagePath: fromPkgPath,
|
63
61
|
fs,
|
64
62
|
});
|
65
|
-
} catch (err) {
|
63
|
+
} catch (err: any) {
|
66
64
|
throw new Error(`Failed to install ${moduleNames}: ${err.message}`);
|
67
65
|
}
|
68
66
|
|
@@ -88,7 +86,7 @@ async function installPeerDependencies(
|
|
88
86
|
module: ModuleRequest,
|
89
87
|
from: FilePath,
|
90
88
|
projectRoot: FilePath,
|
91
|
-
options,
|
89
|
+
options: InstallOptions,
|
92
90
|
) {
|
93
91
|
const {resolved} = await packageManager.resolve(module.name, from);
|
94
92
|
const modulePkg: PackageJSON = nullthrows(
|
@@ -112,6 +110,7 @@ async function installPeerDependencies(
|
|
112
110
|
if (!semver.satisfies(pkg.version, range)) {
|
113
111
|
throw new ThrowableDiagnostic({
|
114
112
|
diagnostic: {
|
113
|
+
// @ts-expect-error TS2345
|
115
114
|
message: md`Could not install the peer dependency "${name}" for "${module.name}", installed version ${pkg.version} is incompatible with ${range}`,
|
116
115
|
origin: '@atlaspack/package-manager',
|
117
116
|
codeFrames: [
|
@@ -205,7 +204,7 @@ export function _addToInstallQueue(
|
|
205
204
|
filePath: FilePath,
|
206
205
|
projectRoot: FilePath,
|
207
206
|
options?: InstallOptions,
|
208
|
-
): Promise<
|
207
|
+
): Promise<unknown> {
|
209
208
|
modules = modules.map((request) => ({
|
210
209
|
name: validateModuleSpecifier(request.name),
|
211
210
|
range: request.range,
|
@@ -248,7 +247,7 @@ export function installPackage(
|
|
248
247
|
filePath: FilePath,
|
249
248
|
projectRoot: FilePath,
|
250
249
|
options?: InstallOptions,
|
251
|
-
): Promise<
|
250
|
+
): Promise<unknown> {
|
252
251
|
if (WorkerFarm.isWorker()) {
|
253
252
|
let workerApi = WorkerFarm.getWorkerApi();
|
254
253
|
// TODO this should really be `__filename` but without the rewriting.
|
@@ -1,8 +1,8 @@
|
|
1
|
-
// @flow
|
2
1
|
import process from 'process';
|
3
2
|
|
4
3
|
// https://nodejs.org/api/packages.html#conditional-exports
|
5
4
|
// TODO We don't support { "type": "module" }
|
5
|
+
// @ts-expect-error TS4104
|
6
6
|
export const defaultNodejsConditions: Array<string> = Object.freeze([
|
7
7
|
'node-addons',
|
8
8
|
'node',
|
@@ -12,24 +12,27 @@ export const defaultNodejsConditions: Array<string> = Object.freeze([
|
|
12
12
|
'default',
|
13
13
|
]);
|
14
14
|
|
15
|
-
let envConditions:
|
15
|
+
let envConditions: undefined | Array<string> = undefined;
|
16
16
|
|
17
17
|
/** @description Gets the export conditions from NODE_OPTIONS and node arguments */
|
18
18
|
export function getConditionsFromEnv(): Array<string> {
|
19
19
|
if (!envConditions) {
|
20
|
-
const conditions = [];
|
20
|
+
const conditions: Array<never> = [];
|
21
21
|
|
22
22
|
for (const arg of [
|
23
23
|
...process.execArgv,
|
24
24
|
...(process.env.NODE_OPTIONS || '').split(' '),
|
25
25
|
]) {
|
26
26
|
if (arg.startsWith('--conditions=')) {
|
27
|
+
// @ts-expect-error TS2345
|
27
28
|
conditions.push(arg.substring(13));
|
28
29
|
}
|
29
30
|
}
|
30
31
|
|
32
|
+
// @ts-expect-error TS4104
|
31
33
|
envConditions = Object.freeze([...conditions, ...defaultNodejsConditions]);
|
32
34
|
}
|
33
35
|
|
36
|
+
// @ts-expect-error TS2322
|
34
37
|
return envConditions;
|
35
38
|
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import type {ChildProcess} from 'child_process';
|
2
|
+
|
3
|
+
export default function promiseFromProcess(
|
4
|
+
childProcess: ChildProcess,
|
5
|
+
): Promise<void> {
|
6
|
+
return new Promise(
|
7
|
+
(
|
8
|
+
resolve: (result: Promise<undefined> | undefined) => void,
|
9
|
+
reject: (error?: any) => void,
|
10
|
+
) => {
|
11
|
+
childProcess.on('error', reject);
|
12
|
+
childProcess.on('close', (code) => {
|
13
|
+
if (code !== 0) {
|
14
|
+
reject(new Error('Child process failed'));
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
|
18
|
+
// @ts-expect-error TS2794
|
19
|
+
resolve();
|
20
|
+
});
|
21
|
+
},
|
22
|
+
);
|
23
|
+
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
// @flow strict-local
|
2
|
-
|
3
1
|
import type {FilePath, ModuleRequest} from '@atlaspack/types';
|
4
2
|
import type {FileSystem} from '@atlaspack/fs';
|
5
3
|
|
@@ -11,8 +9,12 @@ import {promisify} from 'util';
|
|
11
9
|
|
12
10
|
export const exec: (
|
13
11
|
command: string,
|
14
|
-
|
15
|
-
|
12
|
+
// @ts-expect-error TS2503
|
13
|
+
options?: child_process.execOpts,
|
14
|
+
) => Promise<{
|
15
|
+
stdout: string | Buffer;
|
16
|
+
stderr: string | Buffer;
|
17
|
+
}> = _exec
|
16
18
|
? promisify(_exec)
|
17
19
|
: // _exec is undefined in browser builds
|
18
20
|
_exec;
|
@@ -25,10 +27,10 @@ export function npmSpecifierFromModuleRequest(
|
|
25
27
|
: moduleRequest.name;
|
26
28
|
}
|
27
29
|
|
28
|
-
export function moduleRequestsFromDependencyMap(dependencyMap: {
|
29
|
-
[string]: string
|
30
|
-
|
31
|
-
return Object.entries(dependencyMap).map(([name, range]) => {
|
30
|
+
export function moduleRequestsFromDependencyMap(dependencyMap: {
|
31
|
+
[key: string]: string;
|
32
|
+
}): Array<ModuleRequest> {
|
33
|
+
return Object.entries(dependencyMap).map(([name, range]: [any, any]) => {
|
32
34
|
invariant(typeof range === 'string');
|
33
35
|
return {
|
34
36
|
name,
|
@@ -42,7 +44,15 @@ export async function getConflictingLocalDependencies(
|
|
42
44
|
name: string,
|
43
45
|
local: FilePath,
|
44
46
|
projectRoot: FilePath,
|
45
|
-
): Promise
|
47
|
+
): Promise<
|
48
|
+
| {
|
49
|
+
json: string;
|
50
|
+
filePath: FilePath;
|
51
|
+
fields: Array<string>;
|
52
|
+
}
|
53
|
+
| null
|
54
|
+
| undefined
|
55
|
+
> {
|
46
56
|
let pkgPath = await resolveConfig(fs, local, ['package.json'], projectRoot);
|
47
57
|
if (pkgPath == null) {
|
48
58
|
return;
|
@@ -52,7 +62,7 @@ export async function getConflictingLocalDependencies(
|
|
52
62
|
let pkg;
|
53
63
|
try {
|
54
64
|
pkg = JSON.parse(pkgStr);
|
55
|
-
} catch (e) {
|
65
|
+
} catch (e: any) {
|
56
66
|
// TODO: codeframe
|
57
67
|
throw new ThrowableDiagnostic({
|
58
68
|
diagnostic: {
|
@@ -72,7 +82,7 @@ export async function getConflictingLocalDependencies(
|
|
72
82
|
});
|
73
83
|
}
|
74
84
|
|
75
|
-
let fields = [];
|
85
|
+
let fields: Array<string> = [];
|
76
86
|
for (let field of ['dependencies', 'devDependencies', 'peerDependencies']) {
|
77
87
|
if (
|
78
88
|
typeof pkg[field] === 'object' &&
|
@@ -1,5 +1,3 @@
|
|
1
|
-
// @flow strict-local
|
2
|
-
|
3
1
|
import {MemoryFS, NodeFS, OverlayFS} from '@atlaspack/fs';
|
4
2
|
import assert from 'assert';
|
5
3
|
import invariant from 'assert';
|
@@ -8,15 +6,17 @@ import sinon from 'sinon';
|
|
8
6
|
import ThrowableDiagnostic from '@atlaspack/diagnostic';
|
9
7
|
import {loadConfig} from '@atlaspack/utils';
|
10
8
|
import WorkerFarm from '@atlaspack/workers';
|
9
|
+
import {WORKER_PATH} from '@atlaspack/core';
|
11
10
|
import {MockPackageInstaller, NodePackageManager} from '../src';
|
12
11
|
|
13
12
|
const FIXTURES_DIR = path.join(__dirname, 'fixtures');
|
13
|
+
const ROOT_DIR = path.normalize(path.join(__dirname, '..', '..', '..', '..'));
|
14
14
|
|
15
|
-
function normalize(res) {
|
15
|
+
function normalize(res: any) {
|
16
16
|
return {
|
17
17
|
...res,
|
18
18
|
invalidateOnFileCreate:
|
19
|
-
res?.invalidateOnFileCreate?.sort((a, b) => {
|
19
|
+
res?.invalidateOnFileCreate?.sort((a: any, b: any) => {
|
20
20
|
let ax =
|
21
21
|
a.filePath ??
|
22
22
|
a.glob ??
|
@@ -34,22 +34,22 @@ function normalize(res) {
|
|
34
34
|
};
|
35
35
|
}
|
36
36
|
|
37
|
-
function check(resolved, expected) {
|
37
|
+
function check(resolved: any, expected: any) {
|
38
38
|
assert.deepEqual(normalize(resolved), normalize(expected));
|
39
39
|
}
|
40
40
|
|
41
41
|
describe('NodePackageManager', function () {
|
42
|
-
let fs;
|
43
|
-
let packageManager;
|
44
|
-
let packageInstaller;
|
45
|
-
let workerFarm;
|
42
|
+
let fs: any;
|
43
|
+
let packageManager: any;
|
44
|
+
let packageInstaller: any;
|
45
|
+
let workerFarm: any;
|
46
46
|
|
47
47
|
// These can sometimes take a lil while
|
48
48
|
this.timeout(20000);
|
49
49
|
|
50
50
|
beforeEach(() => {
|
51
51
|
workerFarm = new WorkerFarm({
|
52
|
-
workerPath:
|
52
|
+
workerPath: WORKER_PATH,
|
53
53
|
});
|
54
54
|
fs = new OverlayFS(new MemoryFS(workerFarm), new NodeFS());
|
55
55
|
packageInstaller = new MockPackageInstaller();
|
@@ -75,6 +75,8 @@ describe('NodePackageManager', function () {
|
|
75
75
|
type: 1,
|
76
76
|
invalidateOnFileChange: new Set([
|
77
77
|
path.join(FIXTURES_DIR, 'has-foo/node_modules/foo/package.json'),
|
78
|
+
path.join(ROOT_DIR, '/packages/core/package-manager/tsconfig.json'),
|
79
|
+
path.join(ROOT_DIR, 'tsconfig.json'),
|
78
80
|
]),
|
79
81
|
invalidateOnFileCreate: [
|
80
82
|
{
|
@@ -129,6 +131,8 @@ describe('NodePackageManager', function () {
|
|
129
131
|
type: 1,
|
130
132
|
invalidateOnFileChange: new Set([
|
131
133
|
path.join(FIXTURES_DIR, 'has-foo/node_modules/a/package.json'),
|
134
|
+
path.join(ROOT_DIR, '/packages/core/package-manager/tsconfig.json'),
|
135
|
+
path.join(ROOT_DIR, 'tsconfig.json'),
|
132
136
|
]),
|
133
137
|
invalidateOnFileCreate: [
|
134
138
|
{
|
@@ -159,7 +163,6 @@ describe('NodePackageManager', function () {
|
|
159
163
|
it('does not autoinstall packages that are already listed in package.json', async () => {
|
160
164
|
packageInstaller.register('a', fs, path.join(FIXTURES_DIR, 'packages/a'));
|
161
165
|
|
162
|
-
// $FlowFixMe assert.rejects is Node 10+
|
163
166
|
await assert.rejects(
|
164
167
|
() =>
|
165
168
|
packageManager.resolve(
|
@@ -167,7 +170,7 @@ describe('NodePackageManager', function () {
|
|
167
170
|
path.join(FIXTURES_DIR, 'has-a-not-yet-installed/index.js'),
|
168
171
|
{shouldAutoInstall: true},
|
169
172
|
),
|
170
|
-
(err) => {
|
173
|
+
(err: any) => {
|
171
174
|
invariant(err instanceof ThrowableDiagnostic);
|
172
175
|
assert(err.message.includes('Run your package manager'));
|
173
176
|
return true;
|
@@ -248,7 +251,6 @@ describe('NodePackageManager', function () {
|
|
248
251
|
path.join(FIXTURES_DIR, 'has-foo/index.js'),
|
249
252
|
);
|
250
253
|
|
251
|
-
// $FlowFixMe assert.rejects is Node 10+
|
252
254
|
await assert.rejects(
|
253
255
|
() =>
|
254
256
|
packageManager.resolve(
|
@@ -258,7 +260,7 @@ describe('NodePackageManager', function () {
|
|
258
260
|
range: '^2.0.0',
|
259
261
|
},
|
260
262
|
),
|
261
|
-
(err) => {
|
263
|
+
(err: any) => {
|
262
264
|
invariant(err instanceof ThrowableDiagnostic);
|
263
265
|
assert.equal(
|
264
266
|
err.message,
|
@@ -301,6 +303,8 @@ describe('NodePackageManager', function () {
|
|
301
303
|
FIXTURES_DIR,
|
302
304
|
'has-foo/subpackage/node_modules/foo/package.json',
|
303
305
|
),
|
306
|
+
path.join(ROOT_DIR, '/packages/core/package-manager/tsconfig.json'),
|
307
|
+
path.join(ROOT_DIR, 'tsconfig.json'),
|
304
308
|
]),
|
305
309
|
invalidateOnFileCreate: [
|
306
310
|
{
|
@@ -359,7 +363,6 @@ describe('NodePackageManager', function () {
|
|
359
363
|
path.join(FIXTURES_DIR, 'packages/peers-2.0'),
|
360
364
|
);
|
361
365
|
|
362
|
-
// $FlowFixMe assert.rejects is Node 10+
|
363
366
|
await assert.rejects(
|
364
367
|
() =>
|
365
368
|
packageManager.resolve(
|
@@ -370,7 +373,7 @@ describe('NodePackageManager', function () {
|
|
370
373
|
shouldAutoInstall: true,
|
371
374
|
},
|
372
375
|
),
|
373
|
-
(err) => {
|
376
|
+
(err: any) => {
|
374
377
|
assert(err instanceof ThrowableDiagnostic);
|
375
378
|
assert.equal(
|
376
379
|
err.message,
|
@@ -1,4 +1,3 @@
|
|
1
|
-
// @flow
|
2
1
|
import assert from 'assert';
|
3
2
|
|
4
3
|
import validateModuleSpecifier from '../src/validateModuleSpecifier';
|
@@ -15,7 +14,7 @@ describe('Validate Module Specifiers', () => {
|
|
15
14
|
];
|
16
15
|
|
17
16
|
assert.deepEqual(
|
18
|
-
modules.map((module) => validateModuleSpecifier(module)),
|
17
|
+
modules.map((module: any) => validateModuleSpecifier(module)),
|
19
18
|
[
|
20
19
|
'@atlaspack/transformer-posthtml',
|
21
20
|
'@some-org/package@v1.0.0',
|
@@ -31,7 +30,7 @@ describe('Validate Module Specifiers', () => {
|
|
31
30
|
let modules = ['./somewhere.js', './hello/world.js', '~/hello/world.js'];
|
32
31
|
|
33
32
|
assert.deepEqual(
|
34
|
-
modules.map((module) => validateModuleSpecifier(module)),
|
33
|
+
modules.map((module: any) => validateModuleSpecifier(module)),
|
35
34
|
['', '', ''],
|
36
35
|
);
|
37
36
|
});
|
package/tsconfig.json
ADDED
package/index.d.ts
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
import type {
|
2
|
-
FilePath,
|
3
|
-
PackageInstaller,
|
4
|
-
PackageManager,
|
5
|
-
PackageManagerResolveResult,
|
6
|
-
} from '@atlaspack/types';
|
7
|
-
import type {FileSystem} from '@atlaspack/fs';
|
8
|
-
|
9
|
-
export type {PackageManagerResolveResult};
|
10
|
-
export type {PackageManagerResolveResult as ResolveResult};
|
11
|
-
|
12
|
-
export type {
|
13
|
-
PackageManager,
|
14
|
-
InstallOptions,
|
15
|
-
InstallerOptions,
|
16
|
-
PackageInstaller,
|
17
|
-
Invalidations,
|
18
|
-
ModuleRequest,
|
19
|
-
} from '@atlaspack/types';
|
20
|
-
|
21
|
-
export const Npm: {
|
22
|
-
new (): PackageInstaller;
|
23
|
-
};
|
24
|
-
export const Pnpm: {
|
25
|
-
new (): PackageInstaller;
|
26
|
-
};
|
27
|
-
export const Yarn: {
|
28
|
-
new (): PackageInstaller;
|
29
|
-
};
|
30
|
-
|
31
|
-
export const MockPackageInstaller: {
|
32
|
-
new (): PackageInstaller;
|
33
|
-
};
|
34
|
-
export const NodePackageManager: {
|
35
|
-
new (
|
36
|
-
fs: FileSystem,
|
37
|
-
projectRoot: FilePath,
|
38
|
-
installer?: PackageInstaller,
|
39
|
-
): PackageManager;
|
40
|
-
};
|
package/lib/index.d.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { PackageManagerResolveResult } from "@atlaspack/types";
|
2
|
-
export type { PackageManager, Invalidations, PackageInstaller, ModuleRequest } from "@atlaspack/types";
|
3
|
-
export * from "./Npm";
|
4
|
-
export * from "./Pnpm";
|
5
|
-
export * from "./Yarn";
|
6
|
-
export * from "./MockPackageInstaller";
|
7
|
-
export * from "./NodePackageManager";
|
8
|
-
export { _addToInstallQueue } from "./installPackage";
|
9
|
-
export type { PackageManagerResolveResult };
|
10
|
-
export type { PackageManagerResolveResult as ResolveResult };
|