submodule-version 2.3.2 → 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.
- package/README.md +103 -20
- package/dist/runner/handleErrors/handleErrors.d.ts +1 -1
- package/dist/runner/handleErrors/handleErrors.js +3 -10
- package/dist/runner/handleErrors/handleErrors.js.map +1 -1
- package/dist/runner/index.js +0 -0
- package/dist/runner/runner.d.ts +4 -0
- package/dist/runner/runner.js +91 -37
- package/dist/runner/runner.js.map +1 -1
- package/dist/src/PubGrub/PubGrub.d.ts +28 -0
- package/dist/src/PubGrub/PubGrub.js +366 -0
- package/dist/src/PubGrub/PubGrub.js.map +1 -0
- package/dist/src/PubGrub/index.d.ts +2 -0
- package/dist/src/PubGrub/index.js +7 -0
- package/dist/src/PubGrub/index.js.map +1 -0
- package/dist/src/PubGrub/types.d.ts +56 -0
- package/dist/src/PubGrub/types.js +3 -0
- package/dist/src/PubGrub/types.js.map +1 -0
- package/dist/src/entryStore.d.ts +16 -0
- package/dist/src/entryStore.js +152 -0
- package/dist/src/entryStore.js.map +1 -0
- package/dist/src/errors.d.ts +28 -0
- package/dist/src/errors.js +30 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/git/api/GithubError.d.ts +4 -0
- package/dist/src/git/api/GithubError.js +11 -0
- package/dist/src/git/api/GithubError.js.map +1 -0
- package/dist/src/git/api/api.d.ts +8 -0
- package/dist/src/git/api/api.js +133 -0
- package/dist/src/git/api/api.js.map +1 -0
- package/dist/src/git/api/index.d.ts +3 -0
- package/dist/src/git/api/index.js +8 -0
- package/dist/src/git/api/index.js.map +1 -0
- package/dist/src/git/git.d.ts +30 -23
- package/dist/src/git/git.js +8 -258
- package/dist/src/git/git.js.map +1 -1
- package/dist/src/git/index.d.ts +1 -0
- package/dist/src/git/index.js +3 -1
- package/dist/src/git/index.js.map +1 -1
- package/dist/src/git/local/index.d.ts +1 -0
- package/dist/src/git/local/index.js +6 -0
- package/dist/src/git/local/index.js.map +1 -0
- package/dist/src/git/local/local.d.ts +26 -0
- package/dist/src/git/local/local.js +288 -0
- package/dist/src/git/local/local.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.js +16 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/printError.d.ts +1 -0
- package/dist/src/printError.js +158 -0
- package/dist/src/printError.js.map +1 -0
- package/dist/src/sv.d.ts +18 -8
- package/dist/src/sv.js +235 -131
- package/dist/src/sv.js.map +1 -1
- package/dist/src/versionUtil/index.d.ts +2 -0
- package/dist/src/versionUtil/index.js +6 -0
- package/dist/src/versionUtil/index.js.map +1 -0
- package/dist/src/versionUtil/versionUtil.d.ts +16 -0
- package/dist/src/versionUtil/versionUtil.js +70 -0
- package/dist/src/versionUtil/versionUtil.js.map +1 -0
- package/package.json +4 -2
- package/runner/handleErrors/handleErrors.ts +3 -10
- package/runner/runner.ts +128 -46
- package/src/PubGrub/PubGrub.ts +578 -0
- package/src/PubGrub/__tests__/PubGrub.test.ts +351 -0
- package/src/PubGrub/index.ts +12 -0
- package/src/PubGrub/types.ts +72 -0
- package/src/__tests__/entryStore.test.ts +248 -0
- package/src/__tests__/printError.test.ts +148 -0
- package/src/__tests__/sv.test.ts +441 -0
- package/src/entryStore.ts +212 -0
- package/src/errors.ts +39 -0
- package/src/git/api/GithubError.ts +5 -0
- package/src/git/api/api.ts +180 -0
- package/src/git/api/index.ts +3 -0
- package/src/git/git.ts +8 -396
- package/src/git/index.ts +1 -0
- package/src/git/local/index.ts +1 -0
- package/src/git/local/local.ts +430 -0
- package/src/index.ts +17 -0
- package/src/printError.ts +189 -0
- package/src/sv.ts +321 -134
- package/src/versionUtil/__tests__/versionUtil.test.ts +62 -0
- package/src/versionUtil/index.ts +2 -0
- package/src/versionUtil/versionUtil.ts +103 -0
- package/tsconfig.json +1 -1
- package/dist/runner/handleErrors/handleBuildGraphError.d.ts +0 -1
- package/dist/runner/handleErrors/handleBuildGraphError.js +0 -42
- package/dist/runner/handleErrors/handleBuildGraphError.js.map +0 -1
- package/dist/runner/handleErrors/handleGitError.d.ts +0 -1
- package/dist/runner/handleErrors/handleGitError.js +0 -27
- package/dist/runner/handleErrors/handleGitError.js.map +0 -1
- package/dist/runner/handleErrors/handleInstallError.d.ts +0 -1
- package/dist/runner/handleErrors/handleInstallError.js +0 -30
- package/dist/runner/handleErrors/handleInstallError.js.map +0 -1
- package/dist/src/__tests__/versionUtil.test.d.ts +0 -1
- package/dist/src/__tests__/versionUtil.test.js +0 -80
- package/dist/src/__tests__/versionUtil.test.js.map +0 -1
- package/dist/src/buildGraph/GraphError.d.ts +0 -11
- package/dist/src/buildGraph/GraphError.js +0 -11
- package/dist/src/buildGraph/GraphError.js.map +0 -1
- package/dist/src/buildGraph/buildGraph.d.ts +0 -8
- package/dist/src/buildGraph/buildGraph.js +0 -100
- package/dist/src/buildGraph/buildGraph.js.map +0 -1
- package/dist/src/buildGraph/index.d.ts +0 -2
- package/dist/src/buildGraph/index.js +0 -8
- package/dist/src/buildGraph/index.js.map +0 -1
- package/dist/src/git/__tests__/parseGitUrl.test.d.ts +0 -1
- package/dist/src/git/__tests__/parseGitUrl.test.js +0 -30
- package/dist/src/git/__tests__/parseGitUrl.test.js.map +0 -1
- package/dist/src/versionUtil.d.ts +0 -13
- package/dist/src/versionUtil.js +0 -79
- package/dist/src/versionUtil.js.map +0 -1
- package/runner/handleErrors/handleBuildGraphError.ts +0 -49
- package/runner/handleErrors/handleGitError.ts +0 -28
- package/runner/handleErrors/handleInstallError.ts +0 -26
- package/src/__tests__/versionUtil.test.ts +0 -96
- package/src/buildGraph/GraphError.ts +0 -12
- package/src/buildGraph/buildGraph.ts +0 -150
- package/src/buildGraph/index.ts +0 -2
- package/src/versionUtil.ts +0 -97
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "submodule-version",
|
|
3
3
|
"description": "Git <S>ubmodule <V>ersioning tool",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"repository": "github:guljeny/submodule-version",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"prepare": "npm run build",
|
|
13
13
|
"test": "npx jest",
|
|
14
|
-
"build": "rm -rf ./dist && npx tsc",
|
|
14
|
+
"build": "rm -rf ./dist && npx tsc && chmod +x dist/runner/index.js",
|
|
15
15
|
"lint": "npx eslint ./src"
|
|
16
16
|
},
|
|
17
17
|
"author": "Yauheni Hul",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"license": "ISC",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/jest": "^29.5.13",
|
|
28
|
+
"@types/semver": "^7.5.8",
|
|
28
29
|
"eslint": "9.9.1",
|
|
29
30
|
"eslint-config-soft": "^1.0.5",
|
|
30
31
|
"ts-jest": "^29.2.5",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"chalk": "^4.1.2",
|
|
35
36
|
"jest": "^29.7.0",
|
|
37
|
+
"semver": "^7.6.3",
|
|
36
38
|
"typescript": "^5.6.2",
|
|
37
39
|
"yargs": "^17.7.2"
|
|
38
40
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { handleInstallError } from './handleInstallError';
|
|
3
|
-
import { handleGitError } from './handleGitError';
|
|
1
|
+
import { printError } from '../../src';
|
|
4
2
|
import { log } from '../log';
|
|
5
3
|
|
|
6
|
-
export const handleErrors = async (error: Error
|
|
7
|
-
|
|
8
|
-
handleBuildGraphError(error),
|
|
9
|
-
handleInstallError(error, gitUrl),
|
|
10
|
-
handleGitError(error),
|
|
11
|
-
]);
|
|
12
|
-
log.error('unhandled error', error.message);
|
|
4
|
+
export const handleErrors = async (error: Error) => {
|
|
5
|
+
log.error(printError(error));
|
|
13
6
|
};
|
package/runner/runner.ts
CHANGED
|
@@ -1,37 +1,106 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import yargs from 'yargs';
|
|
3
|
-
import { SV } from '../src';
|
|
3
|
+
import { SV, SVError } from '../src';
|
|
4
4
|
import { log } from './log';
|
|
5
5
|
import { handleErrors } from './handleErrors';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/* 'A.B.C' → { name: 'C', parent: 'B' } (parent — непосредственный родитель) */
|
|
8
|
+
const splitPath = (modulePath: string): { name: string, parent?: string } => {
|
|
9
|
+
const parts = modulePath.split('.');
|
|
10
|
+
const name = parts.pop() as string;
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
return { name, parent: parts.pop() };
|
|
13
|
+
};
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
const makeEvent = (
|
|
16
|
+
event: (sv: SV, arg: any) => Promise<void>,
|
|
17
|
+
{ skipInit = false } = {},
|
|
18
|
+
) => async (arg: any) => {
|
|
19
|
+
const sv = new SV(process.cwd(), arg.modulesDir);
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
try {
|
|
22
|
+
/* publish умеет работать с ещё не git/npm-инициализированным проектом */
|
|
23
|
+
if (!skipInit) {
|
|
24
|
+
await sv.init();
|
|
19
25
|
}
|
|
20
|
-
|
|
26
|
+
|
|
27
|
+
await event(sv, arg);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
handleErrors(e as Error);
|
|
30
|
+
}
|
|
21
31
|
};
|
|
22
32
|
|
|
23
|
-
const
|
|
24
|
-
const { url: gitUrl, target } = arg as {
|
|
25
|
-
|
|
33
|
+
const put = makeEvent(async (sv, arg) => {
|
|
34
|
+
const { url: gitUrl, target, ver } = arg as {
|
|
35
|
+
url: string,
|
|
36
|
+
target?: string,
|
|
37
|
+
ver?: string,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
await sv.put(gitUrl, ver || target, ver ? target : undefined);
|
|
26
41
|
});
|
|
27
42
|
|
|
28
|
-
const update = makeEvent(async sv => {
|
|
29
|
-
|
|
43
|
+
const update = makeEvent(async (sv, arg) => {
|
|
44
|
+
const { path: modulePath } = arg as { path?: string };
|
|
45
|
+
|
|
46
|
+
if (!modulePath) {
|
|
47
|
+
/* init внутри makeEvent уже пересобрал модули на максимально разрешённые */
|
|
48
|
+
log.message(chalk.green.bold('Modules are up to date!'));
|
|
49
|
+
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { name, parent } = splitPath(modulePath);
|
|
54
|
+
const entry = sv.getResolution()[name];
|
|
55
|
+
|
|
56
|
+
if (!entry) throw new SVError('ADDON_NOT_FOUND', { name });
|
|
57
|
+
|
|
58
|
+
await sv.put(entry.url, '*', parent);
|
|
30
59
|
});
|
|
31
60
|
|
|
32
|
-
const
|
|
33
|
-
const {
|
|
34
|
-
|
|
61
|
+
const del = makeEvent(async (sv, arg) => {
|
|
62
|
+
const { path: modulePath } = arg as {path: string};
|
|
63
|
+
const { name, parent } = splitPath(modulePath);
|
|
64
|
+
|
|
65
|
+
await sv.delete(name, parent);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const listVersions = makeEvent(async (sv, arg) => {
|
|
69
|
+
const { name, installed } = arg as { name?: string, installed?: boolean };
|
|
70
|
+
|
|
71
|
+
if (installed) {
|
|
72
|
+
const resolution = sv.getResolution();
|
|
73
|
+
|
|
74
|
+
if (name && !resolution[name]) {
|
|
75
|
+
throw new SVError('ADDON_NOT_FOUND', { name });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const names = name ? [name] : Object.keys(resolution);
|
|
79
|
+
|
|
80
|
+
await Promise.all(names.map(async moduleName => {
|
|
81
|
+
const version = await sv.currentVersion(moduleName);
|
|
82
|
+
|
|
83
|
+
log.message(
|
|
84
|
+
chalk.bold(moduleName),
|
|
85
|
+
version || chalk.red('no version tag'),
|
|
86
|
+
);
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const versions = sv.listVersions(name);
|
|
93
|
+
|
|
94
|
+
if (name) {
|
|
95
|
+
log.message(chalk.bold(name), (versions as string[]).join(', '));
|
|
96
|
+
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Object.entries(versions as Record<string, string[]>)
|
|
101
|
+
.forEach(([moduleName, moduleVersions]) => {
|
|
102
|
+
log.message(chalk.bold(moduleName), moduleVersions.join(', '));
|
|
103
|
+
});
|
|
35
104
|
});
|
|
36
105
|
|
|
37
106
|
const publish = makeEvent(async (sv, arg) => {
|
|
@@ -50,59 +119,72 @@ const publish = makeEvent(async (sv, arg) => {
|
|
|
50
119
|
chalk.green.bold('version'),
|
|
51
120
|
chalk.bgGreen.black(` ${version} `),
|
|
52
121
|
);
|
|
53
|
-
});
|
|
122
|
+
}, { skipInit: true });
|
|
54
123
|
|
|
55
124
|
const validate = makeEvent(async sv => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Object.entries(result).forEach(([name, entry]) => {
|
|
59
|
-
if (!entry.used.includes(entry.version) && entry.versions.length === 0) {
|
|
60
|
-
log.message(
|
|
61
|
-
chalk.yellow('⚠️ WARN: Module'),
|
|
62
|
-
chalk.bgYellow.black(` ${name} `),
|
|
63
|
-
chalk.yellow('does not contain any version tag!'),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
125
|
+
sv.getResolution();
|
|
67
126
|
|
|
68
127
|
log.message(chalk.green.bold('Everything is up to date!🔥'));
|
|
69
128
|
});
|
|
70
129
|
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
72
130
|
export const s = yargs.scriptName('sv')
|
|
73
|
-
.usage('$0
|
|
131
|
+
.usage('$0 [cmd] [args]')
|
|
132
|
+
.option('modules-dir', {
|
|
133
|
+
type: 'string',
|
|
134
|
+
describe: 'Directory where submodules live'
|
|
135
|
+
+ ' (stored in package.json as sv-dir)',
|
|
136
|
+
})
|
|
74
137
|
.command(
|
|
75
|
-
['
|
|
138
|
+
['$0'],
|
|
76
139
|
'Validate and install modules',
|
|
77
140
|
() => {},
|
|
78
141
|
validate,
|
|
79
142
|
)
|
|
80
143
|
.command(
|
|
81
|
-
['update', 'u'],
|
|
82
|
-
'Update
|
|
83
|
-
|
|
144
|
+
['update [path]', 'u'],
|
|
145
|
+
'Update modules to the latest allowed versions',
|
|
146
|
+
y => y.positional('path', {
|
|
147
|
+
type: 'string',
|
|
148
|
+
describe: 'Module path (A.B.C), all modules when omitted',
|
|
149
|
+
}),
|
|
84
150
|
update,
|
|
85
151
|
)
|
|
86
152
|
.command(
|
|
87
|
-
['
|
|
88
|
-
'Install
|
|
153
|
+
['put <url> [target]', 'install', 'i'],
|
|
154
|
+
'Install a submodule or change its version',
|
|
89
155
|
y => y.positional('url', {
|
|
90
156
|
type: 'string',
|
|
91
|
-
describe: 'Git submodule url',
|
|
157
|
+
describe: 'Git submodule url or installed module name',
|
|
92
158
|
}).positional('target', {
|
|
93
159
|
type: 'string',
|
|
94
|
-
describe: '
|
|
160
|
+
describe: 'Parent module name',
|
|
161
|
+
}).option('ver', {
|
|
162
|
+
type: 'string',
|
|
163
|
+
alias: 'v',
|
|
164
|
+
describe: 'Version to install',
|
|
165
|
+
}),
|
|
166
|
+
put,
|
|
167
|
+
)
|
|
168
|
+
.command(
|
|
169
|
+
['delete <path>', 'remove', 'r'],
|
|
170
|
+
'Delete submodule by path',
|
|
171
|
+
y => y.positional('path', {
|
|
172
|
+
type: 'string',
|
|
173
|
+
describe: 'Submodule path (A.B.C)',
|
|
95
174
|
}),
|
|
96
|
-
|
|
175
|
+
del,
|
|
97
176
|
)
|
|
98
177
|
.command(
|
|
99
|
-
['
|
|
100
|
-
'
|
|
178
|
+
['list-versions [name]', 'ls'],
|
|
179
|
+
'List available versions of all modules or one',
|
|
101
180
|
y => y.positional('name', {
|
|
102
181
|
type: 'string',
|
|
103
|
-
describe: '
|
|
182
|
+
describe: 'Module name',
|
|
183
|
+
}).option('installed', {
|
|
184
|
+
type: 'boolean',
|
|
185
|
+
describe: 'Show installed versions instead of available',
|
|
104
186
|
}),
|
|
105
|
-
|
|
187
|
+
listVersions,
|
|
106
188
|
)
|
|
107
189
|
.command(
|
|
108
190
|
['publish [module]', 'p'],
|