one-way-git-sync 3.0.0 → 3.1.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 +59 -1
- package/dist/index.js +154 -38
- package/dist/index.js.map +1 -1
- package/package.json +36 -35
package/README.md
CHANGED
|
@@ -2,4 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/semantic-release/semantic-release)
|
|
4
4
|
|
|
5
|
-
A tool for synchronizing git
|
|
5
|
+
:arrows_counterclockwise: A tool for synchronizing a destination git repository with a source git repository SAFELY.
|
|
6
|
+
|
|
7
|
+
It provides three features:
|
|
8
|
+
|
|
9
|
+
1. replace the files of a destination repository (`dest repo`) with those of a source repository (`src repo`),
|
|
10
|
+
2. add a replacement commit (`sync commit`) which whose message has the history of the included commits in the src repo and
|
|
11
|
+
3. detect a conflict when a dest repo has a commit which a src repo doesn't have.
|
|
12
|
+
|
|
13
|
+
## How to Use
|
|
14
|
+
|
|
15
|
+
### Initial Usage
|
|
16
|
+
|
|
17
|
+
Since `one-way-git-sync` finds a sync commit from the commit history of the dest repo,
|
|
18
|
+
you need to run `init` subcommand to add an initial sync commit
|
|
19
|
+
by replacing all the files of the dest repo with those of src repo at first.
|
|
20
|
+
The sample command is as follows:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
yarn one-way-git-sync init \
|
|
24
|
+
-d https://github.com/WillBooster/sample-of-one-way-git-sync \
|
|
25
|
+
-p https://github.com/WillBooster/one-way-git-sync/commits/
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Usual Usage
|
|
29
|
+
|
|
30
|
+
If the last commit in the dest repo is a sync commit,
|
|
31
|
+
`one-way-git-sync` safely synchronize the dest repo with the src repo.
|
|
32
|
+
The sample command is as follows:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
yarn one-way-git-sync \
|
|
36
|
+
-d https://github.com/WillBooster/sample-of-one-way-git-sync \
|
|
37
|
+
-p https://github.com/WillBooster/one-way-git-sync/commits/
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### How to Deal with Conflicts
|
|
41
|
+
|
|
42
|
+
If the last commit in the dest repo isn't a sync commit and if it is not first time,
|
|
43
|
+
the dest repo probably has some commits (`conflict commits`) which don't exist in the src repo.
|
|
44
|
+
You need to merge conflict commits in the src repo manually at first,
|
|
45
|
+
then, you need to force synchronizing the dest repo with the src repo.
|
|
46
|
+
The sample commands are as follows:
|
|
47
|
+
|
|
48
|
+
1. `yarn one-way-git-sync` fails then you notice there exist conflict commits
|
|
49
|
+
2. `cd one-way-git-sync`
|
|
50
|
+
3. `git remote add upstream https://github.com/WillBooster/sample-of-one-way-git-sync`
|
|
51
|
+
4. `git merge --allow-unrelated-histories upstream/main`
|
|
52
|
+
5. ```
|
|
53
|
+
yarn one-way-git-sync --force \
|
|
54
|
+
-d https://github.com/WillBooster/sample-of-one-way-git-sync \
|
|
55
|
+
-p https://github.com/WillBooster/one-way-git-sync/commits/
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Example Repository and Example GitHub Actions Workflows
|
|
59
|
+
|
|
60
|
+
- [sample-of-one-way-git-sync](https://github.com/WillBooster/sample-of-one-way-git-sync): an example synchronized repository.
|
|
61
|
+
- [release.yml](.github/workflows/release.yml): releases a new npm package and add a tag automatically in this repository using `semantic-release`.
|
|
62
|
+
- [sync.yml](.github/workflows/sync.yml): it synchronizes `sample-of-one-way-git-sync` repository using `one-way-git-sync` when a new version is released.
|
|
63
|
+
- [force-sync.yml](.github/workflows/force-sync.yml): we can manually trigger this workflow which forces synchronizing `sample-of-one-way-git-sync` repository.
|
package/dist/index.js
CHANGED
|
@@ -2,34 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var helpers = require('yargs/helpers');
|
|
6
|
+
var yargs = require('yargs/yargs');
|
|
5
7
|
var child_process = require('child_process');
|
|
6
8
|
var fsp = require('fs/promises');
|
|
7
9
|
var path = require('path');
|
|
8
10
|
var fse = require('fs-extra');
|
|
9
11
|
var simpleGit = require('simple-git');
|
|
12
|
+
var winston = require('winston');
|
|
10
13
|
|
|
11
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
15
|
|
|
16
|
+
var yargs__default = /*#__PURE__*/_interopDefaultLegacy(yargs);
|
|
13
17
|
var child_process__default = /*#__PURE__*/_interopDefaultLegacy(child_process);
|
|
14
18
|
var fsp__default = /*#__PURE__*/_interopDefaultLegacy(fsp);
|
|
15
19
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
16
20
|
var fse__default = /*#__PURE__*/_interopDefaultLegacy(fse);
|
|
17
21
|
var simpleGit__default = /*#__PURE__*/_interopDefaultLegacy(simpleGit);
|
|
18
22
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const logger = winston.createLogger({
|
|
24
|
+
transports: [new winston.transports.Console({
|
|
25
|
+
format: winston.format.cli({
|
|
26
|
+
colors: {
|
|
27
|
+
error: 'red'
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
23
32
|
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
const syncDirPath = path__default["default"].join('node_modules', '.temp', 'sync-git-repo');
|
|
34
|
+
const ignoreNames = ['.git', 'node_modules'];
|
|
35
|
+
async function sync(opts, init) {
|
|
36
|
+
await fsp__default["default"].mkdir(syncDirPath, {
|
|
37
|
+
recursive: true
|
|
38
|
+
});
|
|
39
|
+
const dirPath = await fsp__default["default"].mkdtemp(path__default["default"].join(syncDirPath, 'repo-'));
|
|
40
|
+
const ret = await syncCore(dirPath, opts, init);
|
|
41
|
+
await fsp__default["default"].rm(dirPath, {
|
|
26
42
|
recursive: true,
|
|
27
43
|
force: true
|
|
28
44
|
});
|
|
29
|
-
|
|
45
|
+
process.exit(ret ? 0 : 1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function syncCore(destRepoPath, opts, init) {
|
|
49
|
+
var _srcLog$latest, _opts$prefix;
|
|
50
|
+
|
|
51
|
+
await simpleGit__default["default"]().clone(opts.dest, destRepoPath, opts.force ? undefined : {
|
|
30
52
|
'--depth': 1
|
|
31
53
|
});
|
|
32
|
-
|
|
54
|
+
logger.verbose('Cloned a destination repo');
|
|
55
|
+
const dstGit = simpleGit__default["default"](destRepoPath);
|
|
33
56
|
|
|
34
57
|
if (opts.branch) {
|
|
35
58
|
try {
|
|
@@ -40,44 +63,54 @@ async function main(opts) {
|
|
|
40
63
|
}
|
|
41
64
|
|
|
42
65
|
const dstLog = await dstGit.log();
|
|
43
|
-
|
|
66
|
+
let from;
|
|
44
67
|
|
|
45
|
-
if (!
|
|
46
|
-
|
|
47
|
-
|
|
68
|
+
if (!init) {
|
|
69
|
+
from = extractCommitHash(dstLog);
|
|
70
|
+
|
|
71
|
+
if (!from) {
|
|
72
|
+
logger.error('No valid commit in destination repo');
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
logger.verbose(`Extracted a valid commit: ${from}`);
|
|
48
77
|
}
|
|
49
78
|
|
|
79
|
+
const srcGit = simpleGit__default["default"]();
|
|
50
80
|
let srcLog;
|
|
51
81
|
|
|
52
82
|
try {
|
|
53
83
|
// '--first-parent' hides children commits of merge commits
|
|
54
|
-
srcLog = await srcGit.log({
|
|
84
|
+
srcLog = await srcGit.log(from ? {
|
|
55
85
|
from,
|
|
56
86
|
to: 'HEAD',
|
|
57
87
|
'--first-parent': undefined
|
|
58
|
-
});
|
|
88
|
+
} : undefined);
|
|
59
89
|
} catch (e) {
|
|
60
|
-
|
|
61
|
-
|
|
90
|
+
logger.error('Failed to get source commit history:', e);
|
|
91
|
+
return false;
|
|
62
92
|
}
|
|
63
93
|
|
|
64
94
|
const latestHash = (_srcLog$latest = srcLog.latest) === null || _srcLog$latest === void 0 ? void 0 : _srcLog$latest.hash;
|
|
65
95
|
|
|
66
96
|
if (!latestHash) {
|
|
67
|
-
|
|
97
|
+
logger.info('No synchronizable commit');
|
|
98
|
+
return true;
|
|
68
99
|
}
|
|
69
100
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
101
|
+
const [destFiles, srcFiles] = await Promise.all([fsp__default["default"].readdir(destRepoPath), fsp__default["default"].readdir('.')]);
|
|
102
|
+
|
|
103
|
+
for (const destFile of destFiles) {
|
|
104
|
+
if (ignoreNames.includes(destFile)) continue;
|
|
105
|
+
await fsp__default["default"].rm(path__default["default"].join(destRepoPath, destFile), {
|
|
73
106
|
recursive: true,
|
|
74
107
|
force: true
|
|
75
108
|
});
|
|
76
109
|
}
|
|
77
110
|
|
|
78
|
-
for (const
|
|
79
|
-
if (ignoreNames.includes(
|
|
80
|
-
fse__default["default"].copySync(
|
|
111
|
+
for (const srcFile of srcFiles) {
|
|
112
|
+
if (ignoreNames.includes(srcFile)) continue;
|
|
113
|
+
fse__default["default"].copySync(srcFile, path__default["default"].join(destRepoPath, srcFile));
|
|
81
114
|
}
|
|
82
115
|
|
|
83
116
|
await dstGit.add('-A');
|
|
@@ -89,15 +122,23 @@ async function main(opts) {
|
|
|
89
122
|
srcTag = child_process__default["default"].execSync(describeCommand).toString().trim();
|
|
90
123
|
}
|
|
91
124
|
|
|
92
|
-
|
|
125
|
+
let prefix = (_opts$prefix = opts.prefix) !== null && _opts$prefix !== void 0 ? _opts$prefix : '';
|
|
126
|
+
|
|
127
|
+
if (prefix && !prefix.endsWith('/')) {
|
|
128
|
+
prefix += '/';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const link = `${prefix}${latestHash}`;
|
|
93
132
|
const title = srcTag ? `sync ${srcTag} (${link})` : `sync ${link}`;
|
|
94
|
-
const body = srcLog.all.map(l => `* ${l.message}`).join('\n\n');
|
|
133
|
+
const body = init ? `Initialize one-way-git-sync by replacing all the files with those of ${opts.dest}` : srcLog.all.map(l => `* ${l.message}`).join('\n\n');
|
|
95
134
|
|
|
96
135
|
try {
|
|
97
136
|
await dstGit.commit(`${title}\n\n${body}`);
|
|
137
|
+
logger.verbose(`Created a commit: ${title}`);
|
|
138
|
+
logger.verbose(` with body: ${body}`);
|
|
98
139
|
} catch (e) {
|
|
99
|
-
|
|
100
|
-
|
|
140
|
+
logger.error('Failed to commit changes:', e);
|
|
141
|
+
return false;
|
|
101
142
|
}
|
|
102
143
|
|
|
103
144
|
const destTag = srcTag || opts.tag;
|
|
@@ -105,14 +146,16 @@ async function main(opts) {
|
|
|
105
146
|
if (destTag) {
|
|
106
147
|
try {
|
|
107
148
|
await dstGit.addTag(destTag);
|
|
149
|
+
logger.verbose(`Created a tag: ${destTag}`);
|
|
108
150
|
} catch (e) {
|
|
109
|
-
|
|
110
|
-
|
|
151
|
+
logger.error('Failed to commit changes:', e);
|
|
152
|
+
return false;
|
|
111
153
|
}
|
|
112
154
|
}
|
|
113
155
|
|
|
114
156
|
if (opts.dry) {
|
|
115
|
-
|
|
157
|
+
logger.verbose('Finished dry run');
|
|
158
|
+
return true;
|
|
116
159
|
}
|
|
117
160
|
|
|
118
161
|
try {
|
|
@@ -124,17 +167,18 @@ async function main(opts) {
|
|
|
124
167
|
});
|
|
125
168
|
}
|
|
126
169
|
} catch (e) {
|
|
127
|
-
|
|
128
|
-
|
|
170
|
+
logger.error('Failed to push a commit:', e);
|
|
171
|
+
return false;
|
|
129
172
|
}
|
|
130
173
|
|
|
131
|
-
|
|
174
|
+
logger.verbose('Pushed a commit');
|
|
175
|
+
return true;
|
|
132
176
|
}
|
|
133
177
|
|
|
134
178
|
function extractCommitHash(logResult) {
|
|
135
179
|
if (logResult.all.length === 0) {
|
|
136
|
-
|
|
137
|
-
return
|
|
180
|
+
logger.error('No commit history');
|
|
181
|
+
return;
|
|
138
182
|
}
|
|
139
183
|
|
|
140
184
|
for (const log of logResult.all) {
|
|
@@ -145,9 +189,81 @@ function extractCommitHash(logResult) {
|
|
|
145
189
|
}
|
|
146
190
|
}
|
|
147
191
|
|
|
148
|
-
|
|
149
|
-
return
|
|
192
|
+
logger.error('No sync commit: ', logResult.all[0]);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const initCommand = {
|
|
197
|
+
command: 'init',
|
|
198
|
+
describe: 'Initialize a destination git repository',
|
|
199
|
+
|
|
200
|
+
async handler(argv) {
|
|
201
|
+
await sync(argv, true);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const syncCommand = {
|
|
207
|
+
command: 'sync',
|
|
208
|
+
describe: 'Synchronize a destination git repository with a source git repository',
|
|
209
|
+
|
|
210
|
+
async handler(argv) {
|
|
211
|
+
await sync(argv, false);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const yargsOptions = {
|
|
217
|
+
dest: {
|
|
218
|
+
type: 'string',
|
|
219
|
+
alias: 'd',
|
|
220
|
+
describe: 'A URL of a destination git repository.',
|
|
221
|
+
demand: true
|
|
222
|
+
},
|
|
223
|
+
prefix: {
|
|
224
|
+
type: 'string',
|
|
225
|
+
alias: 'p',
|
|
226
|
+
describe: `A prefix of a commit hash used to generate a commit title, e.g. 'sync <prefix>/<hash>'.
|
|
227
|
+
A typical value is like 'https://github.com/WillBooster/one-way-git-sync/commits'`
|
|
228
|
+
},
|
|
229
|
+
branch: {
|
|
230
|
+
type: 'string',
|
|
231
|
+
alias: 'b',
|
|
232
|
+
describe: 'Specify branch of destination repo.'
|
|
233
|
+
},
|
|
234
|
+
tag: {
|
|
235
|
+
type: 'string',
|
|
236
|
+
alias: 't',
|
|
237
|
+
describe: 'Specify tag to be created in destination repo.'
|
|
238
|
+
},
|
|
239
|
+
'tag-hash': {
|
|
240
|
+
type: 'boolean',
|
|
241
|
+
describe: 'Create version+hash tag (e.g. v1.31.5-2-gcdde507). It should be a unique tag.'
|
|
242
|
+
},
|
|
243
|
+
'tag-version': {
|
|
244
|
+
type: 'boolean',
|
|
245
|
+
describe: 'Create version tag (e.g. v1.31.5). It could be a non-unique tag.'
|
|
246
|
+
},
|
|
247
|
+
dry: {
|
|
248
|
+
type: 'boolean',
|
|
249
|
+
describe: 'Enable dry-run mode.'
|
|
250
|
+
},
|
|
251
|
+
force: {
|
|
252
|
+
type: 'boolean',
|
|
253
|
+
describe: 'Force to overwrite the destination git repository.'
|
|
254
|
+
},
|
|
255
|
+
verbose: {
|
|
256
|
+
type: 'boolean',
|
|
257
|
+
alias: 'v',
|
|
258
|
+
describe: 'Show details logs.'
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
async function cli(argv) {
|
|
263
|
+
await yargs__default["default"](helpers.hideBin(argv)).options(yargsOptions).middleware(argv => {
|
|
264
|
+
logger.level = argv.verbose ? 'verbose' : 'info';
|
|
265
|
+
}).command(initCommand).command(syncCommand).argv;
|
|
150
266
|
}
|
|
151
267
|
|
|
152
|
-
exports.
|
|
268
|
+
exports.cli = cli;
|
|
153
269
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import child_process from 'child_process';\nimport fsp from 'fs/promises';\nimport path from 'path';\n\nimport fse from 'fs-extra';\nimport simpleGit, { SimpleGit } from 'simple-git';\nimport type { LogResult } from 'simple-git/typings/response';\nimport { InferredOptionTypes } from 'yargs';\n\nimport { yargsOptions } from './yargsOptions';\n\nconst SYNC_DIR_PATH = '../sync-git-repo';\nconst ignoreNames = ['.git', 'node_modules'];\n\nexport async function main(opts: InferredOptionTypes<typeof yargsOptions>): Promise<void> {\n const srcGit: SimpleGit = simpleGit();\n\n await fsp.rm(SYNC_DIR_PATH, { recursive: true, force: true });\n await srcGit.clone(opts.dest, SYNC_DIR_PATH, opts.force ? undefined : { '--depth': 1 });\n console.log('Cloned a destination repo.');\n\n const dstGit: SimpleGit = simpleGit(SYNC_DIR_PATH);\n if (opts.branch) {\n try {\n await dstGit.checkout(opts.branch);\n } catch (_) {\n await dstGit.checkoutLocalBranch(opts.branch);\n }\n }\n const dstLog = await dstGit.log();\n\n const from = extractCommitHash(dstLog);\n if (!from) {\n console.error('No valid commit in destination repo.');\n process.exit(1);\n }\n console.log(`Extracted a valid commit: ${from}`);\n\n let srcLog: LogResult;\n try {\n // '--first-parent' hides children commits of merge commits\n srcLog = await srcGit.log({ from, to: 'HEAD', '--first-parent': undefined });\n } catch (e) {\n console.error('Failed to get source commit history:', e);\n process.exit(1);\n }\n\n const latestHash = srcLog.latest?.hash;\n if (!latestHash) {\n console.log('No synchronizable commit.');\n process.exit(0);\n }\n\n for (const name of await fsp.readdir(SYNC_DIR_PATH)) {\n if (ignoreNames.includes(name)) continue;\n await fsp.rm(path.join(SYNC_DIR_PATH, name), { recursive: true, force: true });\n }\n for (const name of await fsp.readdir('.')) {\n if (ignoreNames.includes(name)) continue;\n fse.copySync(name, path.join(SYNC_DIR_PATH, name));\n }\n await dstGit.add('-A');\n\n let srcTag = '';\n if (opts['tag-hash'] || opts['tag-version']) {\n // e.g. `--abbrev=0` changes `v1.31.5-2-gcdde507` to `v1.31.5`\n const describeCommand = `git describe --tags --always ${opts['tag-version'] ? '--abbrev=0' : ''}`;\n srcTag = child_process.execSync(describeCommand).toString().trim();\n }\n const link = `${opts.prefix || ''}${latestHash}`;\n const title = srcTag ? `sync ${srcTag} (${link})` : `sync ${link}`;\n const body = srcLog.all.map((l) => `* ${l.message}`).join('\\n\\n');\n try {\n await dstGit.commit(`${title}\\n\\n${body}`);\n console.log(`Created a commit: ${title}`);\n console.log(`${body}`);\n } catch (e) {\n console.error('Failed to commit changes:', e);\n process.exit(1);\n }\n\n const destTag = srcTag || opts.tag;\n if (destTag) {\n try {\n await dstGit.addTag(destTag);\n console.log(`Created a tag: ${destTag}`);\n } catch (e) {\n console.error('Failed to commit changes:', e);\n process.exit(1);\n }\n }\n\n if (opts.dry) {\n console.log('Finished dry run');\n process.exit(0);\n }\n\n try {\n await dstGit.push();\n if (destTag) {\n await dstGit.push({ '--tags': null });\n }\n } catch (e) {\n console.error('Failed to push a commit:', e);\n process.exit(1);\n }\n\n console.log('Pushed');\n process.exit(0);\n}\n\nfunction extractCommitHash(logResult: LogResult): string | null {\n if (logResult.all.length === 0) {\n console.error('No commit history.');\n return null;\n }\n\n for (const log of logResult.all) {\n const [head, ...words] = log.message.replace(/[()]/g, '').split(/[\\s/]/);\n if (head === 'sync' && words.length) {\n return words[words.length - 1];\n }\n }\n console.error('No sync commit: ', logResult.all[0]);\n return null;\n}\n"],"names":["SYNC_DIR_PATH","ignoreNames","main","opts","srcGit","simpleGit","fsp","rm","recursive","force","clone","dest","undefined","dstGit","branch","checkout","_","checkoutLocalBranch","dstLog","log","from","extractCommitHash","console","error","process","exit","srcLog","to","e","latestHash","latest","hash","name","readdir","includes","path","join","fse","copySync","add","srcTag","describeCommand","child_process","execSync","toString","trim","link","prefix","title","body","all","map","l","message","commit","destTag","tag","addTag","dry","push","logResult","length","head","words","replace","split"],"mappings":";;;;;;;;;;;;;;;;;;AAWA,MAAMA,aAAa,GAAG,kBAAtB;AACA,MAAMC,WAAW,GAAG,CAAC,MAAD,EAAS,cAAT,CAApB;AAEO,eAAeC,IAAf,CAAoBC,IAApB,EAAmF;AAAA;;AACxF,QAAMC,MAAiB,GAAGC,6BAAS,EAAnC;AAEA,QAAMC,uBAAG,CAACC,EAAJ,CAAOP,aAAP,EAAsB;AAAEQ,IAAAA,SAAS,EAAE,IAAb;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAAtB,CAAN;AACA,QAAML,MAAM,CAACM,KAAP,CAAaP,IAAI,CAACQ,IAAlB,EAAwBX,aAAxB,EAAuCG,IAAI,CAACM,KAAL,GAAaG,SAAb,GAAyB;AAAE,eAAW;AAAb,GAAhE,CAAN;AAGA,QAAMC,MAAiB,GAAGR,6BAAS,CAACL,aAAD,CAAnC;;AACA,MAAIG,IAAI,CAACW,MA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C,aAAOE,KAAK,CAACA,KAAK,CAACF,MAAN,GAAe,CAAhB,CAAZ;AACD;AACF;;AACDvC,EAAAA,OAAO,CAACC,KAAR,CAAc,kBAAd,EAAkCqC,SAAS,CAACV,GAAV,CAAc,CAAd,CAAlC;AACA,SAAO,IAAP;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/logger.ts","../src/index.ts","../src/initCommand.ts","../src/syncCommand.ts","../src/yargsOptions.ts","../src/cli.ts"],"sourcesContent":["import { createLogger, format, transports } from 'winston';\n\nexport const logger = createLogger({\n transports: [\n new transports.Console({\n format: format.cli({ colors: { error: 'red' } }),\n }),\n ],\n});\n","import child_process from 'child_process';\nimport fsp from 'fs/promises';\nimport path from 'path';\n\nimport fse from 'fs-extra';\nimport simpleGit, { SimpleGit } from 'simple-git';\nimport type { LogResult } from 'simple-git/typings/response';\nimport { InferredOptionTypes } from 'yargs';\n\nimport { logger } from './logger';\nimport { yargsOptions } from './yargsOptions';\n\nconst syncDirPath = path.join('node_modules', '.temp', 'sync-git-repo');\nconst ignoreNames = ['.git', 'node_modules'];\n\nexport async function sync(opts: InferredOptionTypes<typeof yargsOptions>, init: boolean): Promise<void> {\n await fsp.mkdir(syncDirPath, { recursive: true });\n const dirPath = await fsp.mkdtemp(path.join(syncDirPath, 'repo-'));\n const ret = await syncCore(dirPath, opts, init);\n await fsp.rm(dirPath, { recursive: true, force: true });\n process.exit(ret ? 0 : 1);\n}\n\nasync function syncCore(\n destRepoPath: string,\n opts: InferredOptionTypes<typeof yargsOptions>,\n init: boolean\n): Promise<boolean> {\n await simpleGit().clone(opts.dest, destRepoPath, opts.force ? undefined : { '--depth': 1 });\n logger.verbose('Cloned a destination repo');\n\n const dstGit: SimpleGit = simpleGit(destRepoPath);\n if (opts.branch) {\n try {\n await dstGit.checkout(opts.branch);\n } catch (_) {\n await dstGit.checkoutLocalBranch(opts.branch);\n }\n }\n const dstLog = await dstGit.log();\n\n let from: string | undefined;\n if (!init) {\n from = extractCommitHash(dstLog);\n if (!from) {\n logger.error('No valid commit in destination repo');\n return false;\n }\n logger.verbose(`Extracted a valid commit: ${from}`);\n }\n\n const srcGit: SimpleGit = simpleGit();\n let srcLog: LogResult;\n try {\n // '--first-parent' hides children commits of merge commits\n srcLog = await srcGit.log(from ? { from, to: 'HEAD', '--first-parent': undefined } : undefined);\n } catch (e) {\n logger.error('Failed to get source commit history:', e);\n return false;\n }\n\n const latestHash = srcLog.latest?.hash;\n if (!latestHash) {\n logger.info('No synchronizable commit');\n return true;\n }\n\n const [destFiles, srcFiles] = await Promise.all([fsp.readdir(destRepoPath), fsp.readdir('.')]);\n for (const destFile of destFiles) {\n if (ignoreNames.includes(destFile)) continue;\n await fsp.rm(path.join(destRepoPath, destFile), { recursive: true, force: true });\n }\n for (const srcFile of srcFiles) {\n if (ignoreNames.includes(srcFile)) continue;\n fse.copySync(srcFile, path.join(destRepoPath, srcFile));\n }\n await dstGit.add('-A');\n\n let srcTag = '';\n if (opts['tag-hash'] || opts['tag-version']) {\n // e.g. `--abbrev=0` changes `v1.31.5-2-gcdde507` to `v1.31.5`\n const describeCommand = `git describe --tags --always ${opts['tag-version'] ? '--abbrev=0' : ''}`;\n srcTag = child_process.execSync(describeCommand).toString().trim();\n }\n let prefix = opts.prefix ?? '';\n if (prefix && !prefix.endsWith('/')) {\n prefix += '/';\n }\n const link = `${prefix}${latestHash}`;\n const title = srcTag ? `sync ${srcTag} (${link})` : `sync ${link}`;\n const body = init\n ? `Initialize one-way-git-sync by replacing all the files with those of ${opts.dest}`\n : srcLog.all.map((l) => `* ${l.message}`).join('\\n\\n');\n try {\n await dstGit.commit(`${title}\\n\\n${body}`);\n logger.verbose(`Created a commit: ${title}`);\n logger.verbose(` with body: ${body}`);\n } catch (e) {\n logger.error('Failed to commit changes:', e);\n return false;\n }\n\n const destTag = srcTag || opts.tag;\n if (destTag) {\n try {\n await dstGit.addTag(destTag);\n logger.verbose(`Created a tag: ${destTag}`);\n } catch (e) {\n logger.error('Failed to commit changes:', e);\n return false;\n }\n }\n\n if (opts.dry) {\n logger.verbose('Finished dry run');\n return true;\n }\n\n try {\n await dstGit.push();\n if (destTag) {\n await dstGit.push({ '--tags': null });\n }\n } catch (e) {\n logger.error('Failed to push a commit:', e);\n return false;\n }\n\n logger.verbose('Pushed a commit');\n return true;\n}\n\nfunction extractCommitHash(logResult: LogResult): string | undefined {\n if (logResult.all.length === 0) {\n logger.error('No commit history');\n return;\n }\n\n for (const log of logResult.all) {\n const [head, ...words] = log.message.replace(/[()]/g, '').split(/[\\s/]/);\n if (head === 'sync' && words.length) {\n return words[words.length - 1];\n }\n }\n logger.error('No sync commit: ', logResult.all[0]);\n return;\n}\n","import type { CommandModule, InferredOptionTypes } from 'yargs';\n\nimport { yargsOptions } from './yargsOptions';\n\nimport { sync } from './index';\n\nexport const initCommand: CommandModule<unknown, InferredOptionTypes<typeof yargsOptions>> = {\n command: 'init',\n describe: 'Initialize a destination git repository',\n async handler(argv) {\n await sync(argv, true);\n },\n};\n","import type { CommandModule, InferredOptionTypes } from 'yargs';\n\nimport { yargsOptions } from './yargsOptions';\n\nimport { sync } from './index';\n\nexport const syncCommand: CommandModule<unknown, InferredOptionTypes<typeof yargsOptions>> = {\n command: 'sync',\n describe: 'Synchronize a destination git repository with a source git repository',\n async handler(argv) {\n await sync(argv, false);\n },\n};\n","export const yargsOptions = {\n dest: {\n type: 'string',\n alias: 'd',\n describe: 'A URL of a destination git repository.',\n demand: true,\n },\n prefix: {\n type: 'string',\n alias: 'p',\n describe: `A prefix of a commit hash used to generate a commit title, e.g. 'sync <prefix>/<hash>'.\n A typical value is like 'https://github.com/WillBooster/one-way-git-sync/commits'`,\n },\n branch: {\n type: 'string',\n alias: 'b',\n describe: 'Specify branch of destination repo.',\n },\n tag: {\n type: 'string',\n alias: 't',\n describe: 'Specify tag to be created in destination repo.',\n },\n 'tag-hash': {\n type: 'boolean',\n describe: 'Create version+hash tag (e.g. v1.31.5-2-gcdde507). It should be a unique tag.',\n },\n 'tag-version': {\n type: 'boolean',\n describe: 'Create version tag (e.g. v1.31.5). It could be a non-unique tag.',\n },\n dry: {\n type: 'boolean',\n describe: 'Enable dry-run mode.',\n },\n force: {\n type: 'boolean',\n describe: 'Force to overwrite the destination git repository.',\n },\n verbose: {\n type: 'boolean',\n alias: 'v',\n describe: 'Show details logs.',\n },\n} as const;\n","import { hideBin } from 'yargs/helpers';\nimport yargs from 'yargs/yargs';\n\nimport { initCommand } from './initCommand';\nimport { logger } from './logger';\nimport { syncCommand } from './syncCommand';\nimport { yargsOptions } from './yargsOptions';\n\nexport async function cli(argv: string[]): Promise<void> {\n await yargs(hideBin(argv))\n .options(yargsOptions)\n .middleware((argv) => {\n logger.level = argv.verbose ? 'verbose' : 'info';\n })\n .command(initCommand)\n .command(syncCommand).argv;\n}\n"],"names":["logger","createLogger","transports","Console","format","cli","colors","error","syncDirPath","path","join","ignoreNames","sync","opts","init","fsp","mkdir","recursive","dirPath","mkdtemp","ret","syncCore","rm","force","process","exit","destRepoPath","simpleGit","clone","dest","undefined","verbose","dstGit","branch","checkout","_","checkoutLocalBranch","dstLog","log","from","extractCommitHash","srcGit","srcLog","to","e","latestHash","latest","hash","info","destFiles","srcFiles","Promise","all","readdir","destFile","includes","srcFile","fse","copySync","add","srcTag","describeCommand","child_process","execSync","toString","trim","prefix","endsWith","link","title","body","map","l","message","commit","destTag","tag","addTag","dry","push","logResult","length","head","words","replace","split","initCommand","command","describe","handler","argv","syncCommand","yargsOptions","type","alias","demand","yargs","hideBin","options","middleware","level"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEO,MAAMA,MAAM,GAAGC,oBAAY,CAAC;AACjCC,EAAAA,UAAU,EAAE,CACV,IAAIA,kBAAU,CAACC,OAAf,CAAuB;AACrBC,IAAAA,MAAM,EAAEA,cAAM,CAACC,GAAP,CAAW;AAAEC,MAAAA,MAAM,EAAE;AAAEC,QAAAA,KAAK,EAAE;AAAT;AAAV,KAAX;AADa,GAAvB,CADU;A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AJG,EAKHwD,OALG,CAKKD,WALL,EAMHC,OANG,CAMKI,WANL,EAMkBD,IANxB;AAOD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "one-way-git-sync",
|
|
3
|
-
"description": "A tool for synchronizing git
|
|
3
|
+
"description": "A tool for synchronizing a destination git repository with a source git repository SAFELY.",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"git",
|
|
6
6
|
"sync"
|
|
@@ -18,66 +18,67 @@
|
|
|
18
18
|
"cleanup": "yarn format && yarn lint-fix",
|
|
19
19
|
"format": "sort-package-json && yarn prettify",
|
|
20
20
|
"_postinstall": "husky install",
|
|
21
|
-
"lint": "eslint --color \"./{src,__tests__}/**/*.{js,jsx,ts,tsx}\"",
|
|
21
|
+
"lint": "eslint --color \"./{src,__tests__}/**/*.{cjs,js,jsx,mjs,ts,tsx}\"",
|
|
22
22
|
"lint-fix": "yarn lint --fix",
|
|
23
23
|
"prepublishOnly": "pinst --disable",
|
|
24
|
-
"prettify": "prettier --color --write \"**/{.*/,}*.{css,htm,html,js,json,json5,jsx,md,scss,ts,tsx,vue,yaml,yml}\" \"!**/test-fixtures/**\"",
|
|
24
|
+
"prettify": "prettier --color --write \"**/{.*/,}*.{cjs,css,htm,html,js,json,json5,jsx,md,mjs,scss,ts,tsx,vue,yaml,yml}\" \"!**/test-fixtures/**\"",
|
|
25
25
|
"postpublish": "pinst --enable",
|
|
26
|
-
"start": "
|
|
27
|
-
"start-prod": "yarn
|
|
26
|
+
"start": "babel-node -x .js,.jsx,.es6,.es,.ts -- src/start.ts",
|
|
27
|
+
"start-prod": "yarn build && yarn one-way-git-sync",
|
|
28
28
|
"typecheck": "tsc --noEmit --Pretty"
|
|
29
29
|
},
|
|
30
30
|
"prettier": "@willbooster/prettier-config",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"fs-extra": "10.0.0",
|
|
33
|
-
"simple-git": "2.
|
|
34
|
-
"
|
|
33
|
+
"simple-git": "2.48.0",
|
|
34
|
+
"winston": "3.3.3",
|
|
35
|
+
"yargs": "17.3.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@babel/core": "7.16.
|
|
38
|
-
"@babel/helper-plugin-utils": "7.
|
|
39
|
-
"@babel/node": "7.16.
|
|
40
|
-
"@babel/plugin-proposal-class-properties": "7.16.
|
|
41
|
-
"@babel/plugin-proposal-numeric-separator": "7.16.
|
|
42
|
-
"@babel/preset-env": "7.16.
|
|
43
|
-
"@babel/preset-typescript": "7.16.
|
|
38
|
+
"@babel/core": "7.16.5",
|
|
39
|
+
"@babel/helper-plugin-utils": "7.16.5",
|
|
40
|
+
"@babel/node": "7.16.5",
|
|
41
|
+
"@babel/plugin-proposal-class-properties": "7.16.5",
|
|
42
|
+
"@babel/plugin-proposal-numeric-separator": "7.16.5",
|
|
43
|
+
"@babel/preset-env": "7.16.5",
|
|
44
|
+
"@babel/preset-typescript": "7.16.5",
|
|
44
45
|
"@rollup/plugin-babel": "5.3.0",
|
|
45
46
|
"@rollup/plugin-commonjs": "21.0.1",
|
|
46
|
-
"@rollup/plugin-node-resolve": "13.
|
|
47
|
-
"@types/eslint": "
|
|
47
|
+
"@rollup/plugin-node-resolve": "13.1.1",
|
|
48
|
+
"@types/eslint": "8.2.1",
|
|
48
49
|
"@types/fs-extra": "9.0.13",
|
|
49
50
|
"@types/micromatch": "4.0.2",
|
|
50
|
-
"@types/semantic-release": "17.2.
|
|
51
|
-
"@types/yargs": "17.0.
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
53
|
-
"@typescript-eslint/parser": "5.
|
|
54
|
-
"@willbooster/eslint-config-ts": "6.
|
|
55
|
-
"@willbooster/prettier-config": "6.
|
|
56
|
-
"@willbooster/renovate-config": "6.
|
|
51
|
+
"@types/semantic-release": "17.2.3",
|
|
52
|
+
"@types/yargs": "17.0.7",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "5.8.0",
|
|
54
|
+
"@typescript-eslint/parser": "5.8.0",
|
|
55
|
+
"@willbooster/eslint-config-ts": "6.5.0",
|
|
56
|
+
"@willbooster/prettier-config": "6.5.0",
|
|
57
|
+
"@willbooster/renovate-config": "6.5.0",
|
|
57
58
|
"babel-plugin-transform-remove-console": "6.9.4",
|
|
58
59
|
"babel-plugin-unassert": "3.2.0",
|
|
59
60
|
"babel-preset-power-assert": "3.0.0",
|
|
60
61
|
"conventional-changelog-conventionalcommits": "4.6.1",
|
|
61
|
-
"core-js": "3.
|
|
62
|
-
"eslint": "8.
|
|
62
|
+
"core-js": "3.20.0",
|
|
63
|
+
"eslint": "8.5.0",
|
|
63
64
|
"eslint-config-prettier": "8.3.0",
|
|
64
65
|
"eslint-import-resolver-node": "0.3.6",
|
|
65
|
-
"eslint-plugin-import": "2.25.
|
|
66
|
+
"eslint-plugin-import": "2.25.3",
|
|
66
67
|
"husky": "7.0.4",
|
|
67
|
-
"lint-staged": "
|
|
68
|
+
"lint-staged": "12.1.3",
|
|
68
69
|
"micromatch": "4.0.4",
|
|
69
70
|
"pinst": "2.1.6",
|
|
70
71
|
"power-assert": "1.6.1",
|
|
71
|
-
"prettier": "2.
|
|
72
|
-
"rollup": "2.
|
|
73
|
-
"rollup-plugin-node-externals": "
|
|
74
|
-
"semantic-release": "18.0.
|
|
75
|
-
"sort-package-json": "1.
|
|
76
|
-
"typescript": "4.
|
|
72
|
+
"prettier": "2.5.1",
|
|
73
|
+
"rollup": "2.61.1",
|
|
74
|
+
"rollup-plugin-node-externals": "3.1.2",
|
|
75
|
+
"semantic-release": "18.0.1",
|
|
76
|
+
"sort-package-json": "1.53.1",
|
|
77
|
+
"typescript": "4.5.4"
|
|
77
78
|
},
|
|
78
79
|
"engines": {
|
|
79
80
|
"node": ">=14"
|
|
80
81
|
},
|
|
81
|
-
"packageManager": "yarn@3.
|
|
82
|
-
"version": "3.
|
|
82
|
+
"packageManager": "yarn@3.1.1",
|
|
83
|
+
"version": "3.1.2"
|
|
83
84
|
}
|