@pnpm/assert-project 1.1.0 → 1.2.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/LICENSE +2 -1
- package/README.md +1 -3
- package/lib/index.d.ts +33 -17
- package/lib/index.js +104 -105
- package/lib/index.js.map +1 -1
- package/lib/isExecutable.d.ts +1 -3
- package/lib/isExecutable.js +15 -19
- package/lib/isExecutable.js.map +1 -1
- package/package.json +27 -40
package/LICENSE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2022 Zoltan Kochan and other contributors
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> Utils for testing projects that use pnpm
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@pnpm/assert-project) [](https://travis-ci.org/pnpm/assert-project)
|
|
6
|
-
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
9
7
|
```
|
|
@@ -27,4 +25,4 @@ test('...', t => {
|
|
|
27
25
|
|
|
28
26
|
## License
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
MIT
|
package/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { Lockfile, ProjectSnapshot } from '@pnpm/lockfile-types';
|
|
2
|
+
import { Modules } from '@pnpm/modules-yaml';
|
|
3
3
|
import isExecutable from './isExecutable';
|
|
4
|
-
export { isExecutable };
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
export { isExecutable, Modules };
|
|
5
|
+
export declare type RawLockfile = Lockfile & Partial<ProjectSnapshot>;
|
|
6
|
+
export interface Project {
|
|
7
|
+
requireModule: (moduleName: string) => any;
|
|
8
|
+
dir: () => string;
|
|
9
|
+
has: (pkgName: string, modulesDir?: string) => Promise<void>;
|
|
10
|
+
hasNot: (pkgName: string, modulesDir?: string) => Promise<void>;
|
|
11
|
+
getStorePath: () => Promise<string>;
|
|
12
|
+
resolve: (pkgName: string, version?: string, relativePath?: string) => Promise<string>;
|
|
13
|
+
getPkgIndexFilePath: (pkgName: string, version?: string) => Promise<string>;
|
|
14
|
+
cafsHas: (pkgName: string, version?: string) => Promise<void>;
|
|
15
|
+
cafsHasNot: (pkgName: string, version?: string) => Promise<void>;
|
|
16
|
+
storeHas: (pkgName: string, version?: string) => Promise<string>;
|
|
17
|
+
storeHasNot: (pkgName: string, version?: string) => Promise<void>;
|
|
18
|
+
isExecutable: (pathToExe: string) => Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* TODO: Remove the `Required<T>` cast.
|
|
21
|
+
*
|
|
22
|
+
* https://github.com/microsoft/TypeScript/pull/32695 might help with this.
|
|
23
|
+
*/
|
|
24
|
+
readCurrentLockfile: () => Promise<Required<RawLockfile>>;
|
|
25
|
+
readModulesManifest: () => Promise<Modules | null>;
|
|
26
|
+
/**
|
|
27
|
+
* TODO: Remove the `Required<T>` cast.
|
|
28
|
+
*
|
|
29
|
+
* https://github.com/microsoft/TypeScript/pull/32695 might help with this.
|
|
30
|
+
*/
|
|
31
|
+
readLockfile: () => Promise<Required<RawLockfile>>;
|
|
32
|
+
writePackageJson: (pkgJson: object) => Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
declare const _default: (projectPath: string, encodedRegistryName?: string | undefined) => Project;
|
|
19
35
|
export default _default;
|
package/lib/index.js
CHANGED
|
@@ -1,126 +1,125 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
return
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
4
|
};
|
|
10
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
6
|
+
exports.isExecutable = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const assert_store_1 = __importDefault(require("@pnpm/assert-store"));
|
|
9
|
+
const constants_1 = require("@pnpm/constants");
|
|
10
|
+
const modules_yaml_1 = require("@pnpm/modules-yaml");
|
|
11
|
+
const registry_mock_1 = require("@pnpm/registry-mock");
|
|
12
|
+
const read_yaml_file_1 = __importDefault(require("read-yaml-file"));
|
|
13
|
+
const path_exists_1 = __importDefault(require("path-exists"));
|
|
14
|
+
const write_pkg_1 = __importDefault(require("write-pkg"));
|
|
15
|
+
const isExecutable_1 = __importDefault(require("./isExecutable"));
|
|
18
16
|
exports.isExecutable = isExecutable_1.default;
|
|
19
|
-
exports.default = (
|
|
20
|
-
const ern = encodedRegistryName
|
|
21
|
-
const modules =
|
|
22
|
-
let
|
|
23
|
-
|
|
17
|
+
exports.default = (projectPath, encodedRegistryName) => {
|
|
18
|
+
const ern = encodedRegistryName !== null && encodedRegistryName !== void 0 ? encodedRegistryName : `localhost+${registry_mock_1.REGISTRY_MOCK_PORT}`;
|
|
19
|
+
const modules = path_1.default.join(projectPath, 'node_modules');
|
|
20
|
+
let cachedStore;
|
|
21
|
+
async function getStoreInstance() {
|
|
22
|
+
if (!cachedStore) {
|
|
23
|
+
const modulesYaml = await (0, modules_yaml_1.read)(modules);
|
|
24
|
+
if (modulesYaml == null) {
|
|
25
|
+
throw new Error(`Cannot find module store. No .modules.yaml found at "${modules}"`);
|
|
26
|
+
}
|
|
27
|
+
const storePath = modulesYaml.storeDir;
|
|
28
|
+
cachedStore = {
|
|
29
|
+
storePath,
|
|
30
|
+
...(0, assert_store_1.default)(storePath, ern),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return cachedStore;
|
|
34
|
+
}
|
|
35
|
+
async function getVirtualStoreDir() {
|
|
36
|
+
const modulesYaml = await (0, modules_yaml_1.read)(modules);
|
|
37
|
+
if (modulesYaml == null) {
|
|
38
|
+
return path_1.default.join(modules, '.pnpm');
|
|
39
|
+
}
|
|
40
|
+
return modulesYaml.virtualStoreDir;
|
|
41
|
+
}
|
|
42
|
+
// eslint-disable-next-line
|
|
43
|
+
const ok = (value) => expect(value).toBeTruthy();
|
|
44
|
+
// eslint-disable-next-line
|
|
45
|
+
const notOk = (value) => expect(value).toBeFalsy();
|
|
46
|
+
return {
|
|
47
|
+
dir: () => projectPath,
|
|
24
48
|
requireModule(pkgName) {
|
|
25
|
-
|
|
49
|
+
// eslint-disable-next-line
|
|
50
|
+
return require(path_1.default.join(modules, pkgName));
|
|
26
51
|
},
|
|
27
|
-
has(pkgName) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
52
|
+
async has(pkgName, _modulesDir) {
|
|
53
|
+
const md = _modulesDir ? path_1.default.join(projectPath, _modulesDir) : modules;
|
|
54
|
+
ok(await (0, path_exists_1.default)(path_1.default.join(md, pkgName)));
|
|
31
55
|
},
|
|
32
|
-
hasNot(pkgName) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
56
|
+
async hasNot(pkgName, _modulesDir) {
|
|
57
|
+
const md = _modulesDir ? path_1.default.join(projectPath, _modulesDir) : modules;
|
|
58
|
+
notOk(await (0, path_exists_1.default)(path_1.default.join(md, pkgName)));
|
|
36
59
|
},
|
|
37
|
-
getStorePath() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const modulesYaml = yield modulesController_1.read(modules);
|
|
41
|
-
if (!modulesYaml) {
|
|
42
|
-
throw new Error('Cannot find module store');
|
|
43
|
-
}
|
|
44
|
-
cachedStorePath = modulesYaml.store;
|
|
45
|
-
}
|
|
46
|
-
return cachedStorePath;
|
|
47
|
-
});
|
|
60
|
+
async getStorePath() {
|
|
61
|
+
const store = await getStoreInstance();
|
|
62
|
+
return store.storePath;
|
|
48
63
|
},
|
|
49
|
-
resolve(pkgName, version, relativePath) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (relativePath) {
|
|
53
|
-
return path.join(yield project.getStorePath(), pkgFolder, 'package', relativePath);
|
|
54
|
-
}
|
|
55
|
-
return path.join(yield project.getStorePath(), pkgFolder, 'package');
|
|
56
|
-
});
|
|
64
|
+
async resolve(pkgName, version, relativePath) {
|
|
65
|
+
const store = await getStoreInstance();
|
|
66
|
+
return store.resolve(pkgName, version, relativePath);
|
|
57
67
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
t.ok(yield exists(pathToCheck), `${pkgName}@${version} is in store (at ${pathToCheck})`);
|
|
62
|
-
});
|
|
68
|
+
async getPkgIndexFilePath(pkgName, version) {
|
|
69
|
+
const store = await getStoreInstance();
|
|
70
|
+
return store.getPkgIndexFilePath(pkgName, version);
|
|
63
71
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const pathToCheck = yield project.resolve(pkgName, version);
|
|
68
|
-
t.notOk(yield exists(pathToCheck), `${pkgName}@${version} is not in store (at ${pathToCheck})`);
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
if (err.message === 'Cannot find module store') {
|
|
72
|
-
t.pass(`${pkgName}@${version} is not in store`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
throw err;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
72
|
+
async cafsHas(pkgName, version) {
|
|
73
|
+
const store = await getStoreInstance();
|
|
74
|
+
return store.cafsHas(pkgName, version);
|
|
78
75
|
},
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
async cafsHasNot(pkgName, version) {
|
|
77
|
+
const store = await getStoreInstance();
|
|
78
|
+
return store.cafsHasNot(pkgName, version);
|
|
81
79
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return yield loadYamlFile('node_modules/.shrinkwrap.yaml'); // tslint:disable-line
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
if (err.code === 'ENOENT')
|
|
89
|
-
return null;
|
|
90
|
-
throw err;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
80
|
+
async storeHas(pkgName, version) {
|
|
81
|
+
const store = await getStoreInstance();
|
|
82
|
+
return store.resolve(pkgName, version);
|
|
93
83
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
async storeHasNot(pkgName, version) {
|
|
85
|
+
try {
|
|
86
|
+
const store = await getStoreInstance();
|
|
87
|
+
return store.storeHasNot(pkgName, version);
|
|
88
|
+
}
|
|
89
|
+
catch (err) { // eslint-disable-line
|
|
90
|
+
if (err.message.startsWith('Cannot find module store')) {
|
|
91
|
+
return;
|
|
98
92
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return null;
|
|
102
|
-
throw err;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
105
95
|
},
|
|
106
|
-
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
96
|
+
async isExecutable(pathToExe) {
|
|
97
|
+
return (0, isExecutable_1.default)(ok, path_1.default.join(modules, pathToExe));
|
|
98
|
+
},
|
|
99
|
+
async readCurrentLockfile() {
|
|
100
|
+
try {
|
|
101
|
+
return await (0, read_yaml_file_1.default)(path_1.default.join(await getVirtualStoreDir(), 'lock.yaml')); // eslint-disable-line
|
|
102
|
+
}
|
|
103
|
+
catch (err) { // eslint-disable-line
|
|
104
|
+
if (err.code === 'ENOENT')
|
|
105
|
+
return null;
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
readModulesManifest: async () => (0, modules_yaml_1.read)(modules),
|
|
110
|
+
async readLockfile() {
|
|
111
|
+
try {
|
|
112
|
+
return await (0, read_yaml_file_1.default)(path_1.default.join(projectPath, constants_1.WANTED_LOCKFILE)); // eslint-disable-line
|
|
113
|
+
}
|
|
114
|
+
catch (err) { // eslint-disable-line
|
|
115
|
+
if (err.code === 'ENOENT')
|
|
116
|
+
return null;
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
117
119
|
},
|
|
118
|
-
writePackageJson(pkgJson) {
|
|
119
|
-
return
|
|
120
|
-
yield writePkg(projectPath, pkgJson);
|
|
121
|
-
});
|
|
120
|
+
async writePackageJson(pkgJson) {
|
|
121
|
+
return (0, write_pkg_1.default)(projectPath, pkgJson); // eslint-disable-line
|
|
122
122
|
},
|
|
123
123
|
};
|
|
124
|
-
return project;
|
|
125
124
|
};
|
|
126
125
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,sEAA4C;AAC5C,+CAAiD;AAEjD,qDAAiE;AACjE,uDAAwD;AACxD,oEAAyC;AACzC,8DAAgC;AA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,CAAC,sBAAsB;aACrG;YAAC,OAAO,GAAQ,EAAE,EAAE,sBAAsB;gBACzC,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;oBAAE,OAAO,IAAK,CAAA;gBACvC,MAAM,GAAG,CAAA;aACV;QACH,CAAC;QACD,mBAAmB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,mBAAW,EAAC,OAAO,CAAC;QACrD,KAAK,CAAC,YAAY;YAChB,IAAI;gBACF,OAAO,MAAM,IAAA,wBAAY,EAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,2BAAe,CAAC,CAAC,CAAA,CAAC,sBAAsB;aAC1F;YAAC,OAAO,GAAQ,EAAE,EAAE,sBAAsB;gBACzC,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ;oBAAE,OAAO,IAAK,CAAA;gBACvC,MAAM,GAAG,CAAA;aACV;QACH,CAAC;QACD,KAAK,CAAC,gBAAgB,CAAE,OAAe;YACrC,OAAO,IAAA,mBAAQ,EAAC,WAAW,EAAE,OAAc,CAAC,CAAA,CAAC,sBAAsB;QACrE,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
package/lib/isExecutable.d.ts
CHANGED
package/lib/isExecutable.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
return
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
4
|
};
|
|
10
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const IS_WINDOWS =
|
|
16
|
-
const isexe = promisify(
|
|
17
|
-
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const util_1 = require("util");
|
|
8
|
+
const is_windows_1 = __importDefault(require("is-windows"));
|
|
9
|
+
const isexe_1 = __importDefault(require("isexe"));
|
|
10
|
+
const IS_WINDOWS = (0, is_windows_1.default)();
|
|
11
|
+
const isexe = (0, util_1.promisify)(isexe_1.default);
|
|
12
|
+
// eslint-disable-next-line
|
|
13
|
+
exports.default = async (ok, filePath) => {
|
|
18
14
|
if (IS_WINDOWS) {
|
|
19
|
-
|
|
15
|
+
ok(await isexe(`${filePath}.cmd`), `${filePath}.cmd is executable`);
|
|
20
16
|
return;
|
|
21
17
|
}
|
|
22
|
-
const stat =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
18
|
+
const stat = await fs_1.promises.stat(filePath);
|
|
19
|
+
ok((stat.mode & 0o111) === 0o111, `${filePath} is executable`);
|
|
20
|
+
ok(stat.isFile(), `${filePath} refers to a file`);
|
|
21
|
+
};
|
|
26
22
|
//# sourceMappingURL=isExecutable.js.map
|
package/lib/isExecutable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isExecutable.js","sourceRoot":"","sources":["../src/isExecutable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isExecutable.js","sourceRoot":"","sources":["../src/isExecutable.ts"],"names":[],"mappings":";;;;;AAAA,2BAAmC;AACnC,+BAAgC;AAChC,4DAAkC;AAClC,kDAA2B;AAE3B,MAAM,UAAU,GAAG,IAAA,oBAAS,GAAE,CAAA;AAC9B,MAAM,KAAK,GAAG,IAAA,gBAAS,EAAC,eAAO,CAAC,CAAA;AAEhC,2BAA2B;AAC3B,kBAAe,KAAK,EAAE,EAAyC,EAAE,QAAgB,EAAE,EAAE;IACnF,IAAI,UAAU,EAAE;QACd,EAAE,CAAC,MAAM,KAAK,CAAC,GAAG,QAAQ,MAAM,CAAC,EAAE,GAAG,QAAQ,oBAAoB,CAAC,CAAA;QACnE,OAAM;KACP;IAED,MAAM,IAAI,GAAG,MAAM,aAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACpC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,KAAK,EAAE,GAAG,QAAQ,gBAAgB,CAAC,CAAA;IAC9D,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,QAAQ,mBAAmB,CAAC,CAAA;AACnD,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,67 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/assert-project",
|
|
3
3
|
"description": "Utils for testing projects that use pnpm",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Zoltan Kochan",
|
|
7
7
|
"email": "z@kochan.io",
|
|
8
8
|
"url": "https://www.kochan.io/"
|
|
9
9
|
},
|
|
10
10
|
"bugs": {
|
|
11
|
-
"url": "https://github.com/pnpm/
|
|
11
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
12
12
|
},
|
|
13
13
|
"main": "lib/index.js",
|
|
14
|
-
"
|
|
14
|
+
"types": "lib/index.d.ts",
|
|
15
15
|
"files": [
|
|
16
16
|
"lib/"
|
|
17
17
|
],
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"package-preview": "^1.0.0",
|
|
24
|
-
"rimraf": "^2.6.2",
|
|
25
|
-
"ts-node": "^5.0.1",
|
|
26
|
-
"tslint": "^5.4.2",
|
|
27
|
-
"typescript": "^2.7.1"
|
|
19
|
+
"@pnpm/assert-project": "1.2.0",
|
|
20
|
+
"@types/is-windows": "^1.0.0",
|
|
21
|
+
"@types/isexe": "2.0.0",
|
|
22
|
+
"@types/node": "^14.18.20"
|
|
28
23
|
},
|
|
29
24
|
"directories": {
|
|
30
25
|
"test": "test"
|
|
31
26
|
},
|
|
32
|
-
"homepage": "https://github.com/pnpm/assert-project#readme",
|
|
27
|
+
"homepage": "https://github.com/pnpm/pnpm/blob/master/privatePackages/assert-project#readme",
|
|
33
28
|
"keywords": [],
|
|
34
29
|
"license": "MIT",
|
|
35
30
|
"engines": {
|
|
36
|
-
"node": ">=
|
|
31
|
+
"node": ">=10"
|
|
37
32
|
},
|
|
38
|
-
"repository":
|
|
39
|
-
|
|
40
|
-
"
|
|
33
|
+
"repository": "https://github.com/pnpm/pnpm/blob/master/privatePackages/assert-project",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@pnpm/assert-store": "0.0.0",
|
|
36
|
+
"@pnpm/constants": "5.0.0",
|
|
37
|
+
"@pnpm/lockfile-types": "3.2.0",
|
|
38
|
+
"@pnpm/modules-yaml": "9.1.1",
|
|
39
|
+
"@pnpm/registry-mock": "2.19.0",
|
|
40
|
+
"@pnpm/types": "7.10.0",
|
|
41
|
+
"is-windows": "^1.0.2",
|
|
42
|
+
"isexe": "2.0.0",
|
|
43
|
+
"path-exists": "^4.0.0",
|
|
44
|
+
"read-yaml-file": "^2.1.0",
|
|
45
|
+
"write-pkg": "4.0.0"
|
|
41
46
|
},
|
|
42
47
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
-
"commitmsg": "commitlint -e",
|
|
45
|
-
"lint": "tslint -c tslint.json --project .",
|
|
48
|
+
"lint": "tslint -c ../../tslint.json --project .",
|
|
46
49
|
"lint-test": "tslint -c tslint.json --project test",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"test": "npm run lint && npm run lint-test && preview && ts-node test"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@types/mz": "^0.0.32",
|
|
54
|
-
"@types/path-exists": "^3.0.0",
|
|
55
|
-
"@types/tape": "^4.2.32",
|
|
56
|
-
"@types/write-pkg": "^3.1.0",
|
|
57
|
-
"is-windows": "^1.0.2",
|
|
58
|
-
"isexe": "^2.0.0",
|
|
59
|
-
"load-yaml-file": "^0.1.0",
|
|
60
|
-
"mz": "^2.7.0",
|
|
61
|
-
"path-exists": "^3.0.0",
|
|
62
|
-
"supi": "^0.14.4",
|
|
63
|
-
"tape": "^4.9.0",
|
|
64
|
-
"util.promisify": "^1.0.0",
|
|
65
|
-
"write-pkg": "^3.1.0"
|
|
50
|
+
"compile": "rimraf tsconfig.tsbuildinfo lib && tsc --build",
|
|
51
|
+
"pretest": "pnpm install -C test/fixture/project --force --no-shared-workspace-lockfile",
|
|
52
|
+
"test": "pnpm pretest && pnpm run compile && jest"
|
|
66
53
|
}
|
|
67
|
-
}
|
|
54
|
+
}
|