jspm 2.0.0-beta.6 → 3.0.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.
Files changed (100) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +20 -26
  3. package/dist/cli.js +1391 -0
  4. package/jspm.js +10 -0
  5. package/package.json +23 -50
  6. package/CHANGELOG.md +0 -21
  7. package/bin/jspm +0 -46
  8. package/lib/api.d.ts +0 -10
  9. package/lib/api.js +0 -71
  10. package/lib/api.js.map +0 -1
  11. package/lib/build/index.d.ts +0 -24
  12. package/lib/build/index.js +0 -163
  13. package/lib/build/index.js.map +0 -1
  14. package/lib/cli.d.ts +0 -1
  15. package/lib/cli.js +0 -701
  16. package/lib/cli.js.map +0 -1
  17. package/lib/compile/cjs-convert.d.ts +0 -7
  18. package/lib/compile/cjs-convert.js +0 -375
  19. package/lib/compile/cjs-convert.js.map +0 -1
  20. package/lib/compile/dew-resolve.d.ts +0 -9
  21. package/lib/compile/dew-resolve.js +0 -117
  22. package/lib/compile/dew-resolve.js.map +0 -1
  23. package/lib/compile/dew-worker.d.ts +0 -1
  24. package/lib/compile/dew-worker.js +0 -302
  25. package/lib/compile/dew-worker.js.map +0 -1
  26. package/lib/config/config-file.d.ts +0 -67
  27. package/lib/config/config-file.js +0 -591
  28. package/lib/config/config-file.js.map +0 -1
  29. package/lib/config/global-config-file.d.ts +0 -8
  30. package/lib/config/global-config-file.js +0 -89
  31. package/lib/config/global-config-file.js.map +0 -1
  32. package/lib/config/index.d.ts +0 -15
  33. package/lib/config/index.js +0 -59
  34. package/lib/config/index.js.map +0 -1
  35. package/lib/config/jspm-file.d.ts +0 -8
  36. package/lib/config/jspm-file.js +0 -84
  37. package/lib/config/jspm-file.js.map +0 -1
  38. package/lib/config/package-json-file.d.ts +0 -49
  39. package/lib/config/package-json-file.js +0 -332
  40. package/lib/config/package-json-file.js.map +0 -1
  41. package/lib/exec/index.d.ts +0 -12
  42. package/lib/exec/index.js +0 -117
  43. package/lib/exec/index.js.map +0 -1
  44. package/lib/install/bin.d.ts +0 -2
  45. package/lib/install/bin.js +0 -86
  46. package/lib/install/bin.js.map +0 -1
  47. package/lib/install/binary-build.d.ts +0 -2
  48. package/lib/install/binary-build.js +0 -89
  49. package/lib/install/binary-build.js.map +0 -1
  50. package/lib/install/fetch.d.ts +0 -53
  51. package/lib/install/fetch.js +0 -270
  52. package/lib/install/fetch.js.map +0 -1
  53. package/lib/install/index.d.ts +0 -66
  54. package/lib/install/index.js +0 -1164
  55. package/lib/install/index.js.map +0 -1
  56. package/lib/install/package.d.ts +0 -142
  57. package/lib/install/package.js +0 -625
  58. package/lib/install/package.js.map +0 -1
  59. package/lib/install/publish.d.ts +0 -14
  60. package/lib/install/publish.js +0 -186
  61. package/lib/install/publish.js.map +0 -1
  62. package/lib/install/registry-manager.d.ts +0 -134
  63. package/lib/install/registry-manager.js +0 -521
  64. package/lib/install/registry-manager.js.map +0 -1
  65. package/lib/install/source.d.ts +0 -10
  66. package/lib/install/source.js +0 -378
  67. package/lib/install/source.js.map +0 -1
  68. package/lib/map/common.d.ts +0 -13
  69. package/lib/map/common.js +0 -180
  70. package/lib/map/common.js.map +0 -1
  71. package/lib/map/esm-lexer.d.ts +0 -17
  72. package/lib/map/esm-lexer.js +0 -506
  73. package/lib/map/esm-lexer.js.map +0 -1
  74. package/lib/map/index.d.ts +0 -15
  75. package/lib/map/index.js +0 -356
  76. package/lib/map/index.js.map +0 -1
  77. package/lib/map/utils.d.ts +0 -10
  78. package/lib/map/utils.js +0 -181
  79. package/lib/map/utils.js.map +0 -1
  80. package/lib/overrides.d.ts +0 -3
  81. package/lib/overrides.js +0 -29
  82. package/lib/overrides.js.map +0 -1
  83. package/lib/project.d.ts +0 -71
  84. package/lib/project.js +0 -434
  85. package/lib/project.js.map +0 -1
  86. package/lib/utils/cache.d.ts +0 -11
  87. package/lib/utils/cache.js +0 -121
  88. package/lib/utils/cache.js.map +0 -1
  89. package/lib/utils/common.d.ts +0 -55
  90. package/lib/utils/common.js +0 -267
  91. package/lib/utils/common.js.map +0 -1
  92. package/lib/utils/opts.d.ts +0 -6
  93. package/lib/utils/opts.js +0 -200
  94. package/lib/utils/opts.js.map +0 -1
  95. package/lib/utils/run-cmd.d.ts +0 -4
  96. package/lib/utils/run-cmd.js +0 -39
  97. package/lib/utils/run-cmd.js.map +0 -1
  98. package/lib/utils/ui.d.ts +0 -38
  99. package/lib/utils/ui.js +0 -496
  100. package/lib/utils/ui.js.map +0 -1
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /*
4
- * Copyright 2014-2019 Guy Bedford (http://guybedford.com)
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- const path = require("path");
19
- const common_1 = require("../utils/common");
20
- const config_file_1 = require("./config-file");
21
- const mkdirp = require("mkdirp");
22
- const defaultGlobalConfig = {
23
- defaultRegistry: 'npm',
24
- registries: {
25
- github: {},
26
- npm: {}
27
- }
28
- };
29
- class GlobalConfig extends config_file_1.default {
30
- constructor() {
31
- super(path.resolve(common_1.JSPM_CONFIG_DIR, 'config'), [
32
- 'defaultRegistry',
33
- 'strictSSL',
34
- ['timeouts', [
35
- 'download',
36
- 'lookup'
37
- ]],
38
- ['registries', [
39
- ['github', [
40
- 'auth',
41
- 'maxRepoSize'
42
- ]],
43
- ['npm', []]
44
- ]]
45
- ]);
46
- this.read();
47
- // set global config defaults
48
- if (!this.exists()) {
49
- mkdirp.sync(common_1.JSPM_CONFIG_DIR);
50
- this.lock();
51
- // treat legacy jspm configuration file as defaults on first run only
52
- // thus creating a global configuration upgrade path
53
- try {
54
- const legacyGlobalConfig = common_1.readJSONSync(path.join(common_1.JSPM_LEGACY_CONFIG_DIR, 'config'));
55
- if (legacyGlobalConfig)
56
- this.prependObject(legacyGlobalConfig);
57
- }
58
- catch (e) { }
59
- this.prependObject(defaultGlobalConfig);
60
- this.write();
61
- this.unlock();
62
- }
63
- }
64
- get(configName) {
65
- if (typeof configName === 'string')
66
- configName = configName.split('.');
67
- try {
68
- return this.getValue(configName);
69
- }
70
- catch (e) {
71
- return this.getObject(configName);
72
- }
73
- }
74
- set(configName, configValue) {
75
- if (typeof configName === 'string')
76
- configName = configName.split('.');
77
- this.lock();
78
- this.read();
79
- if (configValue !== undefined)
80
- this.setValue(configName, configValue);
81
- else
82
- this.remove(configName);
83
- this.write();
84
- this.unlock();
85
- }
86
- }
87
- exports.GlobalConfig = GlobalConfig;
88
- exports.default = new GlobalConfig();
89
- //# sourceMappingURL=global-config-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global-config-file.js","sourceRoot":"","sources":["../../src/config/global-config-file.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH,6BAA8B;AAE9B,4CAAwF;AACxF,+CAAuC;AACvC,iCAAkC;AAElC,MAAM,mBAAmB,GAAG;IAC1B,eAAe,EAAE,KAAK;IACtB,UAAU,EAAE;QACV,MAAM,EAAE,EAAE;QACV,GAAG,EAAE,EAAE;KACR;CACF,CAAC;AAEF,MAAa,YAAa,SAAQ,qBAAU;IAC1C;QACE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,wBAAe,EAAE,QAAQ,CAAC,EAAE;YAC7C,iBAAiB;YACjB,WAAW;YACX,CAAC,UAAU,EAAE;oBACX,UAAU;oBACV,QAAQ;iBACT,CAAC;YACF,CAAC,YAAY,EAAE;oBACb,CAAC,QAAQ,EAAE;4BACT,MAAM;4BACN,aAAa;yBACd,CAAC;oBACF,CAAC,KAAK,EAAE,EAAE,CAAC;iBACZ,CAAC;SACH,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,EAAE,CAAC;QAEZ,6BAA6B;QAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;YAClB,MAAM,CAAC,IAAI,CAAC,wBAAe,CAAC,CAAC;YAC7B,IAAI,CAAC,IAAI,EAAE,CAAC;YAEZ,qEAAqE;YACrE,oDAAoD;YACpD,IAAI;gBACF,MAAM,kBAAkB,GAAG,qBAAY,CAAC,IAAI,CAAC,IAAI,CAAC,+BAAsB,EAAE,QAAQ,CAAC,CAAC,CAAC;gBACrF,IAAI,kBAAkB;oBACpB,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;aAC1C;YACD,OAAO,CAAC,EAAE,GAAE;YAEZ,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;YAExC,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,EAAE,CAAC;SACf;IACH,CAAC;IAED,GAAG,CAAE,UAA6B;QAChC,IAAI,OAAO,UAAU,KAAK,QAAQ;YAChC,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI;YACF,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;SAClC;QACD,OAAO,CAAC,EAAE;YACR,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;SACnC;IACH,CAAC;IAED,GAAG,CAAE,UAA6B,EAAE,WAA8C;QAChF,IAAI,OAAO,UAAU,KAAK,QAAQ;YAChC,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,IAAI,EAAE,CAAC;QAEZ,IAAI,WAAW,KAAK,SAAS;YAC3B,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;;YAEvC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAE1B,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;CACF;AAlED,oCAkEC;AAED,kBAAe,IAAI,YAAY,EAAE,CAAC"}
@@ -1,15 +0,0 @@
1
- import PackageJsonFile from './package-json-file';
2
- import JspmFile from './jspm-file';
3
- import { default as globalConfig } from './global-config-file';
4
- export { globalConfig };
5
- import { Project } from '../project';
6
- export default class ProjectConfig {
7
- pjson: PackageJsonFile;
8
- jspm: JspmFile;
9
- defaultRegistry: string;
10
- project: Project;
11
- constructor(projectPath: string, project: Project);
12
- dispose(): void;
13
- checkCreatePrompts(force?: boolean): Promise<void>;
14
- save(): boolean;
15
- }
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /*
4
- * Copyright 2014-2019 Guy Bedford (http://guybedford.com)
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- const path = require("path");
19
- const package_json_file_1 = require("./package-json-file");
20
- const jspm_file_1 = require("./jspm-file");
21
- const global_config_file_1 = require("./global-config-file");
22
- exports.globalConfig = global_config_file_1.default;
23
- class ProjectConfig {
24
- constructor(projectPath, project) {
25
- let pjsonPath = path.resolve(projectPath, 'package.json');
26
- this.project = project;
27
- const configFile = path.resolve(path.dirname(pjsonPath), 'jspm.json');
28
- this.jspm = new jspm_file_1.default(configFile);
29
- this.pjson = new package_json_file_1.default(pjsonPath, project, this.jspm.exists());
30
- if (!this.jspm.exists()) {
31
- // check upgrade paths
32
- }
33
- }
34
- dispose() {
35
- this.pjson.dispose();
36
- this.jspm.dispose();
37
- }
38
- async checkCreatePrompts(force = false) {
39
- if (!this.pjson.exists()) {
40
- if (!await this.project.confirm('Package.json file does not exist, create it?', true))
41
- throw 'Operation aborted.';
42
- }
43
- if (!this.jspm.exists()) {
44
- if (!await this.project.confirm(`Configuration file %${path.relative(process.cwd(), this.pjson.configFile)}% does not exist, create it?`, true))
45
- throw 'Operation aborted.';
46
- }
47
- let existingJspmProject = this.pjson.exists() && this.pjson.jspmAware;
48
- if (!existingJspmProject || force)
49
- throw new Error('Init prompts yet to be implemented.');
50
- // await initPrompts(existingJspmProject);
51
- }
52
- save() {
53
- let pjsonChanged = this.pjson.write();
54
- let jspmChanged = this.jspm.write();
55
- return pjsonChanged || jspmChanged;
56
- }
57
- }
58
- exports.default = ProjectConfig;
59
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH,6BAA8B;AAC9B,2DAAkD;AAClD,2CAAmC;AACnC,6DAA+D;AACtD,uBADW,4BAAY,CACX;AAGrB,MAAqB,aAAa;IAMhC,YAAa,WAAmB,EAAE,OAAgB;QAChD,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAE1D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,IAAI,mBAAQ,CAAC,UAAU,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,2BAAe,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAEzE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;YACvB,sBAAsB;SACvB;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAE,KAAK,GAAG,KAAK;QACrC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE;YACxB,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,8CAA8C,EAAE,IAAI,CAAC;gBACnF,MAAM,oBAAoB,CAAC;SAC9B;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;YACvB,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,uBAAuB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,8BAA8B,EAAE,IAAI,CAAC;gBAC7I,MAAM,oBAAoB,CAAC;SAC9B;QAED,IAAI,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAEtE,IAAI,CAAC,mBAAmB,IAAI,KAAK;YAC/B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACvD,0CAA0C;IAC9C,CAAC;IAED,IAAI;QACF,IAAI,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACtC,IAAI,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACpC,OAAO,YAAY,IAAI,WAAW,CAAC;IACrC,CAAC;CACF;AA/CD,gCA+CC"}
@@ -1,8 +0,0 @@
1
- import ConfigFile from './config-file';
2
- import { ResolveTree } from '../install/package';
3
- export default class JspmCfg extends ConfigFile {
4
- installed: ResolveTree;
5
- constructor(configPath: any);
6
- dispose(): void;
7
- write(): boolean;
8
- }
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /*
4
- * Copyright 2014-2019 Guy Bedford (http://guybedford.com)
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- const config_file_1 = require("./config-file");
19
- const package_1 = require("../install/package");
20
- /*
21
- * jspm.json lock file implementation
22
- * Designed to be a system file for jspm first, not humans first.
23
- */
24
- // NB ff we install into a folder, whose jspm configuration file won't be detected as its own when detecting down the backtracking, we throw.
25
- class JspmCfg extends config_file_1.default {
26
- constructor(configPath) {
27
- super(configPath, [
28
- 'resolve',
29
- 'dependencies',
30
- ]);
31
- this.lock();
32
- this.read();
33
- this.installed = new package_1.ResolveTree(this.getObject(['resolve']), this.getObject(['dependencies']));
34
- }
35
- dispose() {
36
- this.unlock();
37
- }
38
- write() {
39
- this.setObject([], this.installed.serialize(), true, true);
40
- // NB for some reason this isn't detecting changelessness
41
- return super.write();
42
- }
43
- }
44
- exports.default = JspmCfg;
45
- /*
46
- getSystemJSConfig () {
47
- let cfg = {
48
- paths: {},
49
- map: {}
50
- };
51
-
52
- function ensureRegistry (registry: string) {
53
- if (cfg.paths[registry + ':'])
54
- return;
55
- cfg.paths[registry + ':'] = toFileURL(this.config.pjson.packages) + '/';
56
- }
57
-
58
- Object.keys(this.resolveMap).forEach(name => {
59
- let pkg = this.resolveMap[name];
60
- ensureRegistry(pkg.registry);
61
-
62
- cfg.map[name + '/'] = pkg.exactName + '/';
63
- let main = this.dependencies[pkg.exactName].main;
64
- if (main)
65
- cfg.map[name] = pkg.exactName + '/' + main;
66
- })
67
-
68
- Object.keys(this.dependencies).forEach(parent => {
69
- let cfgDepMap = cfg.map[parent] = cfg.map[parent] || {};
70
- let depObj = this.dependencies[parent];
71
- Object.keys(depObj.resolveMap).forEach(name => {
72
- let pkgName = depObj.resolveMap[name].exactName;
73
-
74
- cfgDepMap[name + '/'] = pkgName + '/';
75
- let main = this.dependencies[pkgName].main;
76
- if (main)
77
- cfgDepMap[name] = pkgName + '/' + main;
78
- });
79
- });
80
-
81
- return cfg;
82
- }
83
- */
84
- //# sourceMappingURL=jspm-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jspm-file.js","sourceRoot":"","sources":["../../src/config/jspm-file.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;GAcG;AACH,+CAAuC;AACvC,gDAAiD;AAEjD;;;GAGG;AAEH,6IAA6I;AAC7I,MAAqB,OAAQ,SAAQ,qBAAU;IAG7C,YAAa,UAAU;QACrB,KAAK,CAAC,UAAU,EAAE;YAChB,SAAS;YACT,cAAc;SACf,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAClG,CAAC;IAED,OAAO;QACL,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3D,yDAAyD;QACzD,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AAtBD,0BAsBC;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCE"}
@@ -1,49 +0,0 @@
1
- import ConfigFile from './config-file';
2
- import { ProcessedPackageConfig, DepType, PackageTarget } from '../install/package';
3
- import { Project } from '../project';
4
- export default class PackageJson extends ConfigFile {
5
- private jspmPrefix;
6
- private depsPrefixed;
7
- private dir;
8
- private project;
9
- jspmAware: boolean;
10
- name: string;
11
- version: string;
12
- type: string;
13
- src: string;
14
- dist: string;
15
- main: string;
16
- baseURL: string;
17
- packages: string;
18
- private: boolean;
19
- dependencies: {
20
- [name: string]: {
21
- type: DepType;
22
- target: string | PackageTarget;
23
- };
24
- };
25
- overrides: {
26
- target: PackageTarget | string;
27
- override: ProcessedPackageConfig;
28
- fresh: boolean;
29
- }[];
30
- hooks: {
31
- [hook: string]: string;
32
- };
33
- scripts: {
34
- [name: string]: string;
35
- };
36
- configFile: string;
37
- constructor(pjsonPath: string, project: Project, hasJspmConfig: boolean);
38
- dispose(): void;
39
- setBaseURL(baseURL: string): void;
40
- write(): boolean;
41
- setPrefix(jspmPrefix: boolean): void;
42
- private readDependencies;
43
- private writeDependencies;
44
- private prefixedSetObject;
45
- private prefixedSetValue;
46
- private prefixedGetValue;
47
- private prefixedGetObject;
48
- private toRelativePath;
49
- }
@@ -1,332 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /*
4
- * Copyright 2014-2019 Guy Bedford (http://guybedford.com)
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- const config_file_1 = require("./config-file");
19
- const path = require("path");
20
- const package_1 = require("../install/package");
21
- class PackageJson extends config_file_1.default {
22
- constructor(pjsonPath, project, hasJspmConfig) {
23
- super(pjsonPath, [
24
- 'name',
25
- 'version',
26
- 'main',
27
- ['directories', [
28
- 'src',
29
- 'dist',
30
- 'baseURL',
31
- 'packages'
32
- ]],
33
- 'dependencies',
34
- 'devDependencies',
35
- 'peerDependencies',
36
- 'optionalDependencies',
37
- ['jspm', [
38
- 'name',
39
- 'version',
40
- ['directories', [
41
- 'src',
42
- 'dist',
43
- 'baseURL',
44
- 'packages'
45
- ]],
46
- 'dependencies',
47
- 'devDependencies',
48
- 'peerDependencies',
49
- 'optionalDependencies',
50
- 'private',
51
- 'scripts',
52
- ['hooks', [
53
- 'preinstall',
54
- 'postinstall'
55
- ]],
56
- 'overrides'
57
- ]],
58
- 'private',
59
- 'scripts',
60
- 'type',
61
- ['hooks', [
62
- 'preinstall',
63
- 'postinstall'
64
- ]],
65
- 'overrides'
66
- ]);
67
- this.project = project;
68
- this.lock();
69
- this.read();
70
- // auto-inject "type": "module" for jspm projects
71
- this.type = this.getValue(['type'], 'string') || hasJspmConfig && 'module';
72
- this.dir = path.dirname(this.fileName);
73
- this.jspmPrefix = this.has(['jspm']);
74
- this.jspmAware = this.jspmPrefix || this.has(['registry']);
75
- // jspm: true is allowed
76
- try {
77
- if (this.getValue(['jspm'], 'boolean'))
78
- this.jspmPrefix = false;
79
- }
80
- catch (e) { }
81
- //if (!this.jspmAware)
82
- // this.jspmPrefix = true;
83
- this.name = this.prefixedGetValue(['name'], 'string') || !this.jspmAware && 'app';
84
- this.version = this.prefixedGetValue(['version'], 'string');
85
- this.hooks = this.prefixedGetObject(['hooks'], true) || {};
86
- this.scripts = this.prefixedGetObject(['scripts'], false) || {};
87
- this.private = this.prefixedGetValue(['private'], 'boolean');
88
- this.setBaseURL(this.prefixedGetValue(['directories', 'baseURL'], 'string') || '');
89
- this.depsPrefixed = this.jspmPrefix;
90
- if (this.jspmAware &&
91
- !this.has(['jspm', 'dependencies']) &&
92
- !this.has(['jspm', 'peerDependencies']) &&
93
- !this.has(['jspm', 'devDependencies']) &&
94
- !this.has(['jspm', 'optionalDependencies']) &&
95
- (this.has(['dependencies']) ||
96
- this.has(['peerDependencies']) ||
97
- this.has(['devDependencies']) ||
98
- this.has(['optionalDependencies'])))
99
- this.depsPrefixed = false;
100
- this.dependencies = {};
101
- const optionalDependencies = this.readDependencies('optionalDependencies');
102
- if (optionalDependencies)
103
- Object.keys(optionalDependencies).forEach(dep => {
104
- this.dependencies[dep] = {
105
- type: package_1.DepType.optional,
106
- target: package_1.processPackageTarget(dep, optionalDependencies[dep], this.project.defaultRegistry, false)
107
- };
108
- });
109
- const devDependencies = this.readDependencies('devDependencies');
110
- if (devDependencies)
111
- Object.keys(devDependencies).forEach(dep => {
112
- this.dependencies[dep] = {
113
- type: package_1.DepType.dev,
114
- target: package_1.processPackageTarget(dep, devDependencies[dep], this.project.defaultRegistry, false)
115
- };
116
- });
117
- const dependencies = this.readDependencies('dependencies');
118
- if (dependencies)
119
- Object.keys(dependencies).forEach(dep => {
120
- this.dependencies[dep] = {
121
- type: package_1.DepType.primary,
122
- target: package_1.processPackageTarget(dep, dependencies[dep], this.project.defaultRegistry, false)
123
- };
124
- });
125
- const peerDependencies = this.readDependencies('peerDependencies');
126
- if (peerDependencies)
127
- Object.keys(peerDependencies).forEach(dep => {
128
- this.dependencies[dep] = {
129
- type: package_1.DepType.peer,
130
- target: package_1.processPackageTarget(dep, peerDependencies[dep], this.project.defaultRegistry, false)
131
- };
132
- });
133
- const overrides = this.prefixedGetObject(['overrides']);
134
- this.overrides = [];
135
- if (overrides) {
136
- Object.keys(overrides).forEach(name => {
137
- let target;
138
- if (name.match(package_1.resourceInstallRegEx)) {
139
- target = name;
140
- }
141
- else {
142
- const pkgName = package_1.parsePackageName(name);
143
- target = new package_1.PackageTarget(pkgName.registry, pkgName.name, pkgName.version);
144
- }
145
- this.overrides.push({
146
- target,
147
- override: package_1.processPackageConfig(overrides[name]),
148
- fresh: false
149
- });
150
- });
151
- }
152
- }
153
- dispose() {
154
- this.unlock();
155
- }
156
- setBaseURL(baseURL) {
157
- if (baseURL[0] === '/' || baseURL.indexOf('//') !== -1 || baseURL.indexOf('\\\\') !== -1 || baseURL.indexOf(':') !== -1) {
158
- this.project.log.warn('Server baseURL should be a relative file path. Reverting to current project folder.');
159
- baseURL = '';
160
- }
161
- this.baseURL = path.resolve(this.dir, baseURL);
162
- let src = this.prefixedGetValue(['directories', 'src']);
163
- if (src === undefined)
164
- this.src = path.resolve(this.baseURL, 'src');
165
- else
166
- this.src = path.resolve(this.dir, src);
167
- let dist = this.prefixedGetValue(['directories', 'dist']);
168
- if (dist === undefined)
169
- this.dist = path.resolve(this.baseURL, 'dist');
170
- else
171
- this.dist = path.resolve(this.dir, dist);
172
- let packages = this.prefixedGetValue(['directories', 'packages']);
173
- if (packages === undefined)
174
- this.packages = path.resolve(this.baseURL, 'jspm_packages');
175
- else
176
- this.packages = path.resolve(this.dir, packages);
177
- }
178
- write() {
179
- // sync public properties with underlying file representation
180
- if (this.name) {
181
- this.prefixedSetValue(['name'], this.name);
182
- }
183
- else {
184
- this.remove(['name']);
185
- this.remove(['jspm', 'name']);
186
- }
187
- if (this.main)
188
- this.setValue(['main'], this.main);
189
- if (this.type) {
190
- this.remove(['type']);
191
- this.setValue(['type'], this.type);
192
- }
193
- if (this.private !== undefined) {
194
- this.prefixedSetValue(['private'], this.private);
195
- }
196
- const dependencies = {};
197
- const peerDependencies = {};
198
- const devDependencies = {};
199
- const optionalDependencies = {};
200
- Object.keys(this.dependencies).forEach(dep => {
201
- const entry = this.dependencies[dep];
202
- const defaultRegistry = this.project.defaultRegistry;
203
- switch (entry.type) {
204
- case package_1.DepType.primary:
205
- dependencies[dep] = package_1.serializePackageTargetCanonical(dep, entry.target, defaultRegistry);
206
- break;
207
- case package_1.DepType.peer:
208
- peerDependencies[dep] = package_1.serializePackageTargetCanonical(dep, entry.target, defaultRegistry);
209
- break;
210
- case package_1.DepType.dev:
211
- devDependencies[dep] = package_1.serializePackageTargetCanonical(dep, entry.target, defaultRegistry);
212
- break;
213
- case package_1.DepType.optional:
214
- optionalDependencies[dep] = package_1.serializePackageTargetCanonical(dep, entry.target, defaultRegistry);
215
- break;
216
- }
217
- });
218
- this.writeDependencies('dependencies', dependencies);
219
- this.writeDependencies('peerDependencies', peerDependencies);
220
- this.writeDependencies('devDependencies', devDependencies);
221
- this.writeDependencies('optionalDependencies', optionalDependencies);
222
- const overrides = {};
223
- this.overrides.sort(({ target: targetA }, { target: targetB }) => {
224
- if (typeof targetA === 'string')
225
- return typeof targetB === 'string' ? (targetA > targetB ? 1 : -1) : 1;
226
- else if (typeof targetB === 'string')
227
- return -1;
228
- if (targetA.registry !== targetB.registry)
229
- return targetA.registry > targetB.registry ? 1 : -1;
230
- if (targetA.name !== targetB.name)
231
- return targetA.name > targetB.name ? 1 : -1;
232
- return targetA.range.gt(targetB.range) ? 1 : -1;
233
- })
234
- .forEach(({ target, override }) => {
235
- overrides[target.toString()] = package_1.serializePackageConfig(override, typeof target !== 'string' ? target.registry : undefined);
236
- });
237
- this.prefixedSetObject(['overrides'], overrides, !this.jspmPrefix || !this.has(['overrides']));
238
- let baseURL = this.toRelativePath(this.baseURL);
239
- let baseURLPath = baseURL + (baseURL ? '/' : '');
240
- this.prefixedSetValue(['directories', 'baseURL'], baseURL || '.', '.');
241
- this.prefixedSetValue(['directories', 'packages'], this.toRelativePath(this.packages), baseURLPath + 'jspm_packages');
242
- this.prefixedSetValue(['directories', 'src'], this.toRelativePath(this.src) || '.', baseURLPath + 'src');
243
- this.prefixedSetValue(['directories', 'dist'], this.toRelativePath(this.dist), baseURLPath + 'dist');
244
- // always ensure we save as jspm aware
245
- if (!this.has(['jspm']) && !this.has(['registry'])) {
246
- if (this.jspmPrefix)
247
- this.setObject(['jspm'], {});
248
- //else
249
- //this.setValue(['jspm'], true);
250
- }
251
- return super.write();
252
- }
253
- setPrefix(jspmPrefix) {
254
- // removes the "jspm" property in the package.json
255
- // flattening it down the to base-level
256
- if (this.jspmPrefix && this.has(['jspm']) && !jspmPrefix) {
257
- var jspmProperties = this.getProperties(['jspm']);
258
- var baseProperties = this.getProperties([]);
259
- var depsPrefixed = this.depsPrefixed;
260
- if (depsPrefixed) {
261
- this.remove(['dependencies']);
262
- this.remove(['peerDependencies']);
263
- this.remove(['devDependencies']);
264
- }
265
- jspmProperties.forEach(prop => {
266
- this.remove([prop.key]);
267
- baseProperties.push(prop);
268
- });
269
- this.remove(['jspm']);
270
- this.changed = true;
271
- }
272
- else if (!this.jspmPrefix && jspmPrefix) {
273
- if (this.getValue(['jspm']))
274
- this.remove(['jspm']);
275
- }
276
- this.jspmPrefix = this.depsPrefixed = jspmPrefix;
277
- }
278
- readDependencies(depName) {
279
- if (this.depsPrefixed)
280
- return this.getObject(['jspm', depName]);
281
- else
282
- return this.getObject([depName]);
283
- }
284
- writeDependencies(depName, value) {
285
- if (this.depsPrefixed)
286
- return this.setObject(['jspm', depName], value, !this.has(['jspm', depName]));
287
- else
288
- this.setObject([depName], value, !this.has([depName]));
289
- }
290
- prefixedSetObject(memberArray, object, clearIfEmpty = false) {
291
- var prefixed = ['jspm'].concat(memberArray);
292
- var newPrefixed = this.jspmPrefix && !this.jspmAware;
293
- if (!newPrefixed && this.has(prefixed))
294
- this.setObject(prefixed, object, clearIfEmpty);
295
- else if (!newPrefixed && this.has(memberArray))
296
- this.setObject(memberArray, object, clearIfEmpty);
297
- else if (this.jspmPrefix)
298
- this.setObject(prefixed, object, clearIfEmpty);
299
- else
300
- this.setObject(memberArray, object, clearIfEmpty);
301
- }
302
- prefixedSetValue(memberArray, value, defaultValue) {
303
- var prefixed = ['jspm', ...memberArray];
304
- var newPrefixed = this.jspmPrefix && !this.jspmAware;
305
- // if already specified, continue to specify
306
- if (!newPrefixed && this.has(prefixed))
307
- this.setValue(prefixed, value);
308
- else if (!newPrefixed && this.has(memberArray))
309
- this.setValue(memberArray, value);
310
- // otherwise only specify if not default
311
- else if (this.jspmPrefix && value !== defaultValue)
312
- this.setValue(prefixed, value);
313
- else if (value !== defaultValue)
314
- this.setValue(memberArray, value);
315
- }
316
- prefixedGetValue(memberArray, type) {
317
- var value;
318
- if (this.jspmPrefix)
319
- value = this.getValue(['jspm'].concat(memberArray), type);
320
- if (typeof value == 'undefined')
321
- value = this.getValue(memberArray, type);
322
- return value;
323
- }
324
- prefixedGetObject(memberArray, nested = true) {
325
- return this.jspmPrefix && this.getObject(['jspm'].concat(memberArray), nested) || this.getObject(memberArray, nested);
326
- }
327
- toRelativePath(absPath) {
328
- return path.relative(this.dir, absPath).replace(/\\/g, '/');
329
- }
330
- }
331
- exports.default = PackageJson;
332
- //# sourceMappingURL=package-json-file.js.map