submodule-version 2.0.0 → 2.0.2
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 +52 -9
- package/dist/src/buildGraph.d.ts +7 -1
- package/dist/src/buildGraph.js.map +1 -1
- package/dist/src/git.d.ts +1 -1
- package/dist/src/git.js +7 -2
- package/dist/src/git.js.map +1 -1
- package/dist/src/submoduleVersion.js +15 -0
- package/dist/src/submoduleVersion.js.map +1 -1
- package/index-dev.ts +2 -1
- package/package.json +1 -1
- package/src/buildGraph.ts +8 -1
- package/src/git.ts +7 -2
- package/src/submoduleVersion.ts +20 -0
package/README.md
CHANGED
|
@@ -1,17 +1,60 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Submodule version
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Git **S**ubmodule **V**ersion tool
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/submodule-version)
|
|
6
6
|
|
|
7
|
-
`
|
|
7
|
+
`Submodule version` is a tool to manage git submodules as versioned packages.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This tool designet to split projects in-to submodules *without npm-packages headache*.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
With `submodule version` code can be organized like a *single monorepo*, but each submodule can be *easily reused* in another projects like npm-package.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## Problem to solve
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Take a look on the next situation:
|
|
16
16
|
|
|
17
|
-
`
|
|
17
|
+
- Project has 2 submodules `ui-button-element` and `render-engine`
|
|
18
|
+
- Package `ui-button-element` dependents on the `render-engine`
|
|
19
|
+
- Third repo `ui-slider-element` dependets on newest version of the `render-engine`
|
|
20
|
+
|
|
21
|
+
This cause next problems:
|
|
22
|
+
|
|
23
|
+
- Add `ui-slider-element` cause difficulties with handle different `render-engine` versions
|
|
24
|
+
- How to update `ui-button-element` if it's repo contains new version?
|
|
25
|
+
|
|
26
|
+
Submodule version helps to
|
|
27
|
+
|
|
28
|
+
- Take a look which project should be updated and which version should be installed
|
|
29
|
+
- Help update submodules and theirs dependencies
|
|
30
|
+
- Install new submodules
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
- Install sv tool `npm i -D submodule-version`
|
|
35
|
+
- Add `workspaces` section in `package.json`
|
|
36
|
+
```
|
|
37
|
+
"workspaces": [
|
|
38
|
+
"modules/*"
|
|
39
|
+
],
|
|
40
|
+
```
|
|
41
|
+
- Install first submodule `npx sv i <git_repo>`
|
|
42
|
+
- Install npm dependencies `npm i`. Submodule will be linked in node_modules and its dependencies will be installed
|
|
43
|
+
- Use your submodule in code `import submodule from 'submodule-name'` 🔥
|
|
44
|
+
|
|
45
|
+
## How it works
|
|
46
|
+
|
|
47
|
+
- Each submodule and main project has own `package.json` with `sv` object inside. `sv` object will be generated automatically and will contain every dependency version
|
|
48
|
+
```
|
|
49
|
+
"sv": {
|
|
50
|
+
"git@github.com:guljeny/submodule-version.git": "^1.0.0"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
- `Submodule version` creates a graph of whole project and install only possible and actual versions
|
|
54
|
+
|
|
55
|
+
## Commands
|
|
56
|
+
|
|
57
|
+
- `sv validate` - Validate all dependencis and install missing modules
|
|
58
|
+
- `sv install <git_url> [target_submodule]` - Install new dependency
|
|
59
|
+
- `sv update` - Update all dependencies to the latest possible versions
|
|
60
|
+
- `sv help` - Description of all commands
|
package/dist/src/buildGraph.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildGraph.js","sourceRoot":"","sources":["../../src/buildGraph.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,+CAA4C;AAC5C,+BAA4B;AAC5B,+BAA4B;AAC5B,+CAA4C;AAC5C,+CAA4C;
|
|
1
|
+
{"version":3,"file":"buildGraph.js","sourceRoot":"","sources":["../../src/buildGraph.ts"],"names":[],"mappings":";;;;;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C;IAEP,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AA9EW,QAAA,UAAU,cA8ErB"}
|
package/dist/src/git.d.ts
CHANGED
package/dist/src/git.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.git = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
7
8
|
const child_process_1 = require("child_process");
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const config_1 = require("./config");
|
|
@@ -20,10 +21,13 @@ const addSumbmodule = (url) => {
|
|
|
20
21
|
log_1.log.error(url, 'Is not a git repo');
|
|
21
22
|
}
|
|
22
23
|
};
|
|
23
|
-
const checkout = (
|
|
24
|
-
const { name } = (0, parseGitUrl_1.parseGitUrl)(url);
|
|
24
|
+
const checkout = (name, version) => {
|
|
25
25
|
const module = path_1.default.join(config_1.config.dir, name);
|
|
26
|
+
const styledName = chalk_1.default.green.bold(name);
|
|
27
|
+
const styledVer = chalk_1.default.green.bold(version);
|
|
28
|
+
log_1.log.message('Checkout', styledName, 'to', styledVer);
|
|
26
29
|
try {
|
|
30
|
+
(0, child_process_1.execSync)(`git -C ${module} fetch`);
|
|
27
31
|
(0, child_process_1.execSync)(`git -C ${module} checkout ${version} -q`);
|
|
28
32
|
}
|
|
29
33
|
catch {
|
|
@@ -33,6 +37,7 @@ const checkout = (url, version) => {
|
|
|
33
37
|
};
|
|
34
38
|
const listVersions = (projectName) => {
|
|
35
39
|
const module = path_1.default.join(config_1.config.dir, projectName);
|
|
40
|
+
(0, child_process_1.execSync)(`git -C ${module} fetch`);
|
|
36
41
|
const res = (0, child_process_1.execSync)(`git -C ${module} tag -l`);
|
|
37
42
|
const tagList = res.toString().split(/\r?\n/);
|
|
38
43
|
return tagList.filter(tag => {
|
package/dist/src/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAyC;AACzC,gDAAwB;AACxB,qCAAkC;AAClC,+BAA4B;AAC5B,+CAA4C;AAC5C,+CAA4C;AAE5C,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,EAAE;IACpC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,eAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAE3C,IAAI;QACF,IAAA,wBAAQ,EAAC,qBAAqB,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC;KAChD;IAAC,MAAM;QACN,SAAG,CAAC,KAAK,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;KACrC;AACH,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iDAAyC;AACzC,gDAAwB;AACxB,qCAAkC;AAClC,+BAA4B;AAC5B,+CAA4C;AAC5C,+CAA4C;AAE5C,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,EAAE;IACpC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,eAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAE3C,IAAI;QACF,IAAA,wBAAQ,EAAC,qBAAqB,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC;KAChD;IAAC,MAAM;QACN,SAAG,CAAC,KAAK,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;KACrC;AACH,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE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@@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const chalk_1 = __importDefault(require("chalk"));
|
|
7
7
|
const yargs_1 = __importDefault(require("yargs"));
|
|
8
8
|
const buildGraph_1 = require("./buildGraph");
|
|
9
|
+
const versionUtil_1 = require("./versionUtil");
|
|
9
10
|
const install_1 = require("./install");
|
|
10
11
|
const log_1 = require("./log");
|
|
12
|
+
const git_1 = require("./git");
|
|
11
13
|
const mainProcess = () => {
|
|
12
14
|
(0, buildGraph_1.buildGraph)();
|
|
13
15
|
log_1.log.message(chalk_1.default.green.bold('Everything is up to date!🔥'));
|
|
14
16
|
};
|
|
17
|
+
const update = () => {
|
|
18
|
+
const graph = (0, buildGraph_1.buildGraph)();
|
|
19
|
+
if (!graph)
|
|
20
|
+
return;
|
|
21
|
+
Object.entries(graph).forEach(([name, data]) => {
|
|
22
|
+
const { version, used } = data;
|
|
23
|
+
const latestVersion = versionUtil_1.versionUtil.latest(used);
|
|
24
|
+
if (latestVersion !== version) {
|
|
25
|
+
git_1.git.checkout(name, latestVersion);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
15
29
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
16
30
|
yargs_1.default.scriptName('sv')
|
|
17
31
|
.usage('$0 <cmd> [args]')
|
|
18
32
|
.command(['validate', '$0', 'v'], 'Validate and install modules', () => { }, mainProcess)
|
|
33
|
+
.command(['update', 'u'], 'Update git modules to actual versions', () => { }, update)
|
|
19
34
|
.command(['install <url> [target]', 'i'], 'Install new submodule', y => y.positional('url', {
|
|
20
35
|
type: 'string',
|
|
21
36
|
describe: 'Git submodule url',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submoduleVersion.js","sourceRoot":"","sources":["../../src/submoduleVersion.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,kDAA0B;AAC1B,6CAA0C;AAC1C,uCAAoC;AACpC,+BAA4B;AAE5B,MAAM,WAAW,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AAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QAC7C,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC/B,MAAM,aAAa,GAAG,yBAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,aAAa,KAAK,OAAO,EAAE;YAC7B,SAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;SACnC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,oEAAoE;AACpE,eAAK,CAAC,UAAU,CAAC,IAAI,CAAC;KACnB,KAAK,CAAC,iBAAiB,CAAC;KACxB,OAAO,CACN,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,EACvB,8BAA8B,EAC9B,GAAG,EAAE,GAAE,CAAC,EACR,WAAW,CACZ;KACA,OAAO,CACN,CAAC,QAAQ,EAAE,GAAG,CAAC,EACf,uCAAuC,EACvC,GAAG,EAAE,GAAE,CAAC,EACR,MAAM,CACP;KACA,OAAO,CACN,CAAC,wBAAwB,EAAE,GAAG,CAAC,EAC/B,uBAAuB,EACvB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE;IACvB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,mBAAmB;CAC9B,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE;IACtB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,oBAAoB;CAC/B,CAAC,EACF,iBAAO,CACR;KACA,IAAI,EAAE;KACN,IAAI,CAAC"}
|
package/index-dev.ts
CHANGED
package/package.json
CHANGED
package/src/buildGraph.ts
CHANGED
|
@@ -17,7 +17,14 @@ interface ITreeEntry {
|
|
|
17
17
|
|
|
18
18
|
type TBaseTree = Record<string, ITreeEntry>;
|
|
19
19
|
|
|
20
|
-
export
|
|
20
|
+
export interface IGraphEntry {
|
|
21
|
+
versions: string[];
|
|
22
|
+
parents: Record<string, string>;
|
|
23
|
+
used: string[];
|
|
24
|
+
version: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const buildGraph = (): Record<string, IGraphEntry> | void => {
|
|
21
28
|
const baseJson = pkgJsonUtil.read();
|
|
22
29
|
const baseTree: TBaseTree = {};
|
|
23
30
|
|
package/src/git.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
1
2
|
import { execSync } from 'child_process';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import { config } from './config';
|
|
@@ -16,11 +17,14 @@ const addSumbmodule = (url: string) => {
|
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const checkout = (
|
|
20
|
-
const { name } = parseGitUrl(url);
|
|
20
|
+
const checkout = (name: string, version: string) => {
|
|
21
21
|
const module = path.join(config.dir, name);
|
|
22
|
+
const styledName = chalk.green.bold(name);
|
|
23
|
+
const styledVer = chalk.green.bold(version);
|
|
24
|
+
log.message('Checkout', styledName, 'to', styledVer);
|
|
22
25
|
|
|
23
26
|
try {
|
|
27
|
+
execSync(`git -C ${module} fetch`);
|
|
24
28
|
execSync(`git -C ${module} checkout ${version} -q`);
|
|
25
29
|
} catch {
|
|
26
30
|
log.error('Checkout failded');
|
|
@@ -29,6 +33,7 @@ const checkout = (url: string, version: string) => {
|
|
|
29
33
|
|
|
30
34
|
const listVersions = (projectName: string) => {
|
|
31
35
|
const module = path.join(config.dir, projectName);
|
|
36
|
+
execSync(`git -C ${module} fetch`);
|
|
32
37
|
const res = execSync(`git -C ${module} tag -l`);
|
|
33
38
|
const tagList = res.toString().split(/\r?\n/);
|
|
34
39
|
|
package/src/submoduleVersion.ts
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import yargs from 'yargs';
|
|
3
3
|
import { buildGraph } from './buildGraph';
|
|
4
|
+
import { versionUtil } from './versionUtil';
|
|
4
5
|
import { install } from './install';
|
|
5
6
|
import { log } from './log';
|
|
7
|
+
import { git } from './git';
|
|
6
8
|
|
|
7
9
|
const mainProcess = () => {
|
|
8
10
|
buildGraph();
|
|
9
11
|
log.message(chalk.green.bold('Everything is up to date!🔥'));
|
|
10
12
|
};
|
|
11
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
|
+
|
|
12
26
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
13
27
|
yargs.scriptName('sv')
|
|
14
28
|
.usage('$0 <cmd> [args]')
|
|
@@ -18,6 +32,12 @@ yargs.scriptName('sv')
|
|
|
18
32
|
() => {},
|
|
19
33
|
mainProcess,
|
|
20
34
|
)
|
|
35
|
+
.command(
|
|
36
|
+
['update', 'u'],
|
|
37
|
+
'Update git modules to actual versions',
|
|
38
|
+
() => {},
|
|
39
|
+
update,
|
|
40
|
+
)
|
|
21
41
|
.command(
|
|
22
42
|
['install <url> [target]', 'i'],
|
|
23
43
|
'Install new submodule',
|