@atlaspack/package-manager 2.14.18-noselfbuild-63bde801d.0 → 2.14.18-typescript-e769947a5.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/lib/utils.js DELETED
@@ -1,101 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.exec = void 0;
7
- exports.getConflictingLocalDependencies = getConflictingLocalDependencies;
8
- exports.moduleRequestsFromDependencyMap = moduleRequestsFromDependencyMap;
9
- exports.npmSpecifierFromModuleRequest = npmSpecifierFromModuleRequest;
10
- function _assert() {
11
- const data = _interopRequireDefault(require("assert"));
12
- _assert = function () {
13
- return data;
14
- };
15
- return data;
16
- }
17
- function _diagnostic() {
18
- const data = _interopRequireDefault(require("@atlaspack/diagnostic"));
19
- _diagnostic = function () {
20
- return data;
21
- };
22
- return data;
23
- }
24
- function _utils() {
25
- const data = require("@atlaspack/utils");
26
- _utils = function () {
27
- return data;
28
- };
29
- return data;
30
- }
31
- function _child_process() {
32
- const data = require("child_process");
33
- _child_process = function () {
34
- return data;
35
- };
36
- return data;
37
- }
38
- function _util() {
39
- const data = require("util");
40
- _util = function () {
41
- return data;
42
- };
43
- return data;
44
- }
45
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
46
- const exec = exports.exec = _child_process().exec ? (0, _util().promisify)(_child_process().exec) :
47
- // _exec is undefined in browser builds
48
- _child_process().exec;
49
- function npmSpecifierFromModuleRequest(moduleRequest) {
50
- return moduleRequest.range != null ? [moduleRequest.name, moduleRequest.range].join('@') : moduleRequest.name;
51
- }
52
- function moduleRequestsFromDependencyMap(dependencyMap) {
53
- return Object.entries(dependencyMap).map(([name, range]) => {
54
- (0, _assert().default)(typeof range === 'string');
55
- return {
56
- name,
57
- range
58
- };
59
- });
60
- }
61
- async function getConflictingLocalDependencies(fs, name, local, projectRoot) {
62
- let pkgPath = await (0, _utils().resolveConfig)(fs, local, ['package.json'], projectRoot);
63
- if (pkgPath == null) {
64
- return;
65
- }
66
- let pkgStr = await fs.readFile(pkgPath, 'utf8');
67
- let pkg;
68
- try {
69
- pkg = JSON.parse(pkgStr);
70
- } catch (e) {
71
- // TODO: codeframe
72
- throw new (_diagnostic().default)({
73
- diagnostic: {
74
- message: 'Failed to parse package.json',
75
- origin: '@atlaspack/package-manager'
76
- }
77
- });
78
- }
79
- if (typeof pkg !== 'object' || pkg == null) {
80
- // TODO: codeframe
81
- throw new (_diagnostic().default)({
82
- diagnostic: {
83
- message: 'Expected package.json contents to be an object.',
84
- origin: '@atlaspack/package-manager'
85
- }
86
- });
87
- }
88
- let fields = [];
89
- for (let field of ['dependencies', 'devDependencies', 'peerDependencies']) {
90
- if (typeof pkg[field] === 'object' && pkg[field] != null && pkg[field][name] != null) {
91
- fields.push(field);
92
- }
93
- }
94
- if (fields.length > 0) {
95
- return {
96
- filePath: pkgPath,
97
- json: pkgStr,
98
- fields
99
- };
100
- }
101
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = validateModuleSpecifier;
7
- const MODULE_REGEX = /^((@[^/\s]+\/){0,1}([^/\s.~]+[^/\s]*)){1}(@[^/\s]+){0,1}/;
8
- function validateModuleSpecifier(moduleName) {
9
- let matches = MODULE_REGEX.exec(moduleName);
10
- if (matches) {
11
- return matches[0];
12
- }
13
- return '';
14
- }