submodule-version 2.0.4 → 2.1.1

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 (117) hide show
  1. package/dist/runner/handleErrors/handleBuildGraphError.d.ts +1 -0
  2. package/dist/runner/handleErrors/handleBuildGraphError.js +42 -0
  3. package/dist/runner/handleErrors/handleBuildGraphError.js.map +1 -0
  4. package/dist/runner/handleErrors/handleErrors.d.ts +1 -0
  5. package/dist/runner/handleErrors/handleErrors.js +15 -0
  6. package/dist/runner/handleErrors/handleErrors.js.map +1 -0
  7. package/dist/runner/handleErrors/handleGitError.d.ts +1 -0
  8. package/dist/runner/handleErrors/handleGitError.js +18 -0
  9. package/dist/runner/handleErrors/handleGitError.js.map +1 -0
  10. package/dist/runner/handleErrors/handleInstallError.d.ts +1 -0
  11. package/dist/runner/handleErrors/handleInstallError.js +30 -0
  12. package/dist/runner/handleErrors/handleInstallError.js.map +1 -0
  13. package/dist/runner/handleErrors/index.d.ts +1 -0
  14. package/dist/runner/handleErrors/index.js +6 -0
  15. package/dist/runner/handleErrors/index.js.map +1 -0
  16. package/dist/runner/index-dev.d.ts +2 -0
  17. package/dist/runner/index-dev.js +11 -0
  18. package/dist/runner/index-dev.js.map +1 -0
  19. package/dist/runner/index.d.ts +2 -0
  20. package/dist/{index.js → runner/index.js} +1 -1
  21. package/dist/runner/index.js.map +1 -0
  22. package/dist/runner/log.js.map +1 -0
  23. package/dist/runner/runner.d.ts +9 -0
  24. package/dist/runner/runner.js +63 -0
  25. package/dist/runner/runner.js.map +1 -0
  26. package/dist/src/Graph/Graph.d.ts +12 -0
  27. package/dist/src/Graph/Graph.js +85 -0
  28. package/dist/src/Graph/Graph.js.map +1 -0
  29. package/dist/src/Graph/GraphError.d.ts +11 -0
  30. package/dist/src/Graph/GraphError.js +11 -0
  31. package/dist/src/Graph/GraphError.js.map +1 -0
  32. package/dist/src/Graph/index.d.ts +2 -0
  33. package/dist/src/Graph/index.js +8 -0
  34. package/dist/src/Graph/index.js.map +1 -0
  35. package/dist/src/PkgJSONManager.d.ts +6 -0
  36. package/dist/src/PkgJSONManager.js +53 -0
  37. package/dist/src/PkgJSONManager.js.map +1 -0
  38. package/dist/src/git/GitError.d.ts +4 -0
  39. package/dist/src/git/GitError.js +11 -0
  40. package/dist/src/git/GitError.js.map +1 -0
  41. package/dist/src/git/__tests__/parseGitUrl.test.js.map +1 -0
  42. package/dist/src/git/git.d.ts +7 -0
  43. package/dist/src/git/git.js +52 -0
  44. package/dist/src/git/git.js.map +1 -0
  45. package/dist/src/git/index.d.ts +2 -0
  46. package/dist/src/git/index.js +8 -0
  47. package/dist/src/git/index.js.map +1 -0
  48. package/dist/src/{parseGitUrl.d.ts → git/parseGitUrl.d.ts} +1 -2
  49. package/dist/src/git/parseGitUrl.js.map +1 -0
  50. package/dist/src/index.d.ts +1 -0
  51. package/dist/src/index.js +6 -0
  52. package/dist/src/index.js.map +1 -0
  53. package/dist/src/runOptions.d.ts +4 -0
  54. package/dist/src/runOptions.js +9 -0
  55. package/dist/src/runOptions.js.map +1 -0
  56. package/dist/src/sv.d.ts +9 -0
  57. package/dist/src/sv.js +59 -0
  58. package/dist/src/sv.js.map +1 -0
  59. package/dist/src/versionUtil.js.map +1 -1
  60. package/package.json +5 -4
  61. package/runner/handleErrors/handleBuildGraphError.ts +49 -0
  62. package/runner/handleErrors/handleErrors.ts +11 -0
  63. package/runner/handleErrors/handleGitError.ts +16 -0
  64. package/runner/handleErrors/handleInstallError.ts +26 -0
  65. package/runner/handleErrors/index.ts +1 -0
  66. package/{index-dev.ts → runner/index-dev.ts} +2 -2
  67. package/runner/index.ts +3 -0
  68. package/runner/runner.ts +90 -0
  69. package/src/Graph/Graph.ts +121 -0
  70. package/src/Graph/GraphError.ts +12 -0
  71. package/src/Graph/index.ts +2 -0
  72. package/src/PkgJSONManager.ts +57 -0
  73. package/src/git/GitError.ts +5 -0
  74. package/src/git/git.ts +69 -0
  75. package/src/git/index.ts +2 -0
  76. package/src/{parseGitUrl.ts → git/parseGitUrl.ts} +1 -1
  77. package/src/index.ts +1 -0
  78. package/src/runOptions.ts +4 -0
  79. package/src/sv.ts +72 -0
  80. package/tsconfig.json +1 -1
  81. package/dist/index.d.ts +0 -2
  82. package/dist/index.js.map +0 -1
  83. package/dist/src/__tests__/parseGitUrl.test.js.map +0 -1
  84. package/dist/src/buildGraph.d.ts +0 -7
  85. package/dist/src/buildGraph.js +0 -88
  86. package/dist/src/buildGraph.js.map +0 -1
  87. package/dist/src/config.d.ts +0 -4
  88. package/dist/src/config.js +0 -8
  89. package/dist/src/config.js.map +0 -1
  90. package/dist/src/git.d.ts +0 -5
  91. package/dist/src/git.js +0 -55
  92. package/dist/src/git.js.map +0 -1
  93. package/dist/src/install.d.ts +0 -1
  94. package/dist/src/install.js +0 -43
  95. package/dist/src/install.js.map +0 -1
  96. package/dist/src/log.js.map +0 -1
  97. package/dist/src/parseGitUrl.js.map +0 -1
  98. package/dist/src/pkgJsonUtil.d.ts +0 -5
  99. package/dist/src/pkgJsonUtil.js +0 -38
  100. package/dist/src/pkgJsonUtil.js.map +0 -1
  101. package/dist/src/submoduleVersion.d.ts +0 -1
  102. package/dist/src/submoduleVersion.js +0 -43
  103. package/dist/src/submoduleVersion.js.map +0 -1
  104. package/index.ts +0 -3
  105. package/src/buildGraph.ts +0 -126
  106. package/src/config.ts +0 -4
  107. package/src/git.ts +0 -52
  108. package/src/install.ts +0 -47
  109. package/src/pkgJsonUtil.ts +0 -36
  110. package/src/submoduleVersion.ts +0 -54
  111. /package/dist/{src → runner}/log.d.ts +0 -0
  112. /package/dist/{src → runner}/log.js +0 -0
  113. /package/dist/src/{__tests__ → git/__tests__}/parseGitUrl.test.d.ts +0 -0
  114. /package/dist/src/{__tests__ → git/__tests__}/parseGitUrl.test.js +0 -0
  115. /package/dist/src/{parseGitUrl.js → git/parseGitUrl.js} +0 -0
  116. /package/{src → runner}/log.ts +0 -0
  117. /package/src/{__tests__ → git/__tests__}/parseGitUrl.test.ts +0 -0
package/src/install.ts DELETED
@@ -1,47 +0,0 @@
1
- import chalk from "chalk";
2
- import { parseGitUrl } from "./parseGitUrl";
3
- import { pkgJsonUtil } from "./pkgJsonUtil";
4
- import { log } from "./log";
5
- import { git } from "./git";
6
- import { versionUtil } from "./versionUtil";
7
- import { buildGraph } from "./buildGraph";
8
-
9
- interface IArg {
10
- url: string;
11
- target?: string;
12
- }
13
-
14
- /* Yargs typed as any */
15
- export const install = (arg: any) => {
16
- const { target } = arg as IArg;
17
- const { url, version, name } = parseGitUrl(arg.url);
18
-
19
- if (!name) {
20
- return log.error(chalk.red.bold(url), '- is not a git url!');
21
- }
22
-
23
- const targetPkg = pkgJsonUtil.read(target);
24
- let installedPkg = pkgJsonUtil.read(name);
25
-
26
- if (!installedPkg) {
27
- git.addSumbmodule(url);
28
- installedPkg = pkgJsonUtil.read(name);
29
- }
30
-
31
- const versions = git.listVersions(name);
32
- const latestVersion = versionUtil.latest(versions);
33
- const requestedVersion = version || latestVersion;
34
-
35
- if (!versions.includes(requestedVersion) && versions.length) {
36
- const styledName = `Package ${chalk.bold.green(name)}`;
37
- const styledVer = chalk.bgRed.bold.white(` ${requestedVersion} `);
38
- const errMsg = `does not contain version ${styledVer}.`;
39
- const styledVList = chalk.bold.green(versions.join(', '));
40
- const helpMsg = `Use one from [${styledVList}]`;
41
- log.error(styledName, errMsg, helpMsg);
42
- }
43
-
44
- targetPkg.sv[url] = requestedVersion ? `^${requestedVersion}` : '*';
45
- pkgJsonUtil.write(targetPkg, target);
46
- buildGraph();
47
- };
@@ -1,36 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { config } from './config';
4
-
5
- const JSON_NAME = 'package.json';
6
-
7
- const getPkgJsonPath = (name?: string) => {
8
- const folder = name ? [config.dir, name] : [];
9
- const jsonPath = path.join(process.cwd(), ...folder, JSON_NAME);
10
- const isJsonExists = fs.existsSync(jsonPath);
11
- if (!isJsonExists) return null;
12
-
13
- return jsonPath;
14
- };
15
-
16
- const read = (name?: string) => {
17
- const jsonPath = getPkgJsonPath(name);
18
- if (!jsonPath) return null;
19
- const jsonString = fs.readFileSync(jsonPath, 'utf-8');
20
-
21
- return JSON.parse(jsonString);
22
- };
23
-
24
- const write = (data: Object, name?: string) => {
25
- const jsonPath = getPkgJsonPath(name);
26
- if (!jsonPath) return null;
27
- fs.writeFileSync(jsonPath, JSON.stringify(data, null, 2));
28
- };
29
-
30
- export const pkgJsonUtil = {
31
- getPkgJsonPath,
32
- read,
33
- write,
34
- };
35
-
36
- module.exports = { pkgJsonUtil };
@@ -1,54 +0,0 @@
1
- import chalk from 'chalk';
2
- import yargs from 'yargs';
3
- import { buildGraph } from './buildGraph';
4
- import { versionUtil } from './versionUtil';
5
- import { install } from './install';
6
- import { log } from './log';
7
- import { git } from './git';
8
-
9
- const mainProcess = () => {
10
- buildGraph();
11
- log.message(chalk.green.bold('Everything is up to date!🔥'));
12
- };
13
-
14
- const update = () => {
15
- const graph = buildGraph();
16
- if (!graph) return;
17
- Object.entries(graph).forEach(([name, data]) => {
18
- const { version, used } = data;
19
- const latestVersion = versionUtil.latest(used);
20
- if (latestVersion !== version) {
21
- git.checkout(name, latestVersion);
22
- }
23
- });
24
- };
25
-
26
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
27
- yargs.scriptName('sv')
28
- .usage('$0 <cmd> [args]')
29
- .command(
30
- ['validate', '$0', 'v'],
31
- 'Validate and install modules',
32
- () => {},
33
- mainProcess,
34
- )
35
- .command(
36
- ['update', 'u'],
37
- 'Update git modules to actual versions',
38
- () => {},
39
- update,
40
- )
41
- .command(
42
- ['install <url> [target]', 'i'],
43
- 'Install new submodule',
44
- y => y.positional('url', {
45
- type: 'string',
46
- describe: 'Git submodule url',
47
- }).positional('target', {
48
- type: 'string',
49
- describe: 'Target module name',
50
- }),
51
- install,
52
- )
53
- .help()
54
- .argv;
File without changes
File without changes
File without changes
File without changes