git-sync-js 0.4.6 → 1.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 (102) hide show
  1. package/README.md +3 -2
  2. package/dist/src/clone.d.ts +13 -0
  3. package/dist/src/clone.d.ts.map +1 -0
  4. package/dist/src/clone.js +55 -0
  5. package/dist/src/clone.js.map +1 -0
  6. package/dist/src/commitAndSync.d.ts +21 -0
  7. package/dist/src/commitAndSync.d.ts.map +1 -0
  8. package/dist/src/commitAndSync.js +143 -0
  9. package/dist/src/commitAndSync.js.map +1 -0
  10. package/dist/{credential.d.ts → src/credential.d.ts} +3 -2
  11. package/dist/src/credential.d.ts.map +1 -0
  12. package/dist/{credential.js → src/credential.js} +7 -7
  13. package/dist/src/credential.js.map +1 -0
  14. package/dist/{defaultGitInfo.d.ts → src/defaultGitInfo.d.ts} +2 -0
  15. package/dist/src/defaultGitInfo.d.ts.map +1 -0
  16. package/dist/{defaultGitInfo.js → src/defaultGitInfo.js} +2 -0
  17. package/dist/src/defaultGitInfo.js.map +1 -0
  18. package/dist/{errors.d.ts → src/errors.d.ts} +5 -1
  19. package/dist/src/errors.d.ts.map +1 -0
  20. package/dist/{errors.js → src/errors.js} +5 -5
  21. package/dist/src/errors.js.map +1 -0
  22. package/dist/src/index.d.ts +12 -0
  23. package/dist/src/index.d.ts.map +1 -0
  24. package/dist/src/index.js +12 -0
  25. package/dist/src/index.js.map +1 -0
  26. package/dist/src/init.d.ts +25 -0
  27. package/dist/src/init.d.ts.map +1 -0
  28. package/dist/src/init.js +22 -0
  29. package/dist/src/init.js.map +1 -0
  30. package/dist/src/initGit.d.ts +26 -0
  31. package/dist/src/initGit.d.ts.map +1 -0
  32. package/dist/src/initGit.js +40 -0
  33. package/dist/src/initGit.js.map +1 -0
  34. package/dist/{inspect.d.ts → src/inspect.d.ts} +20 -7
  35. package/dist/src/inspect.d.ts.map +1 -0
  36. package/dist/{inspect.js → src/inspect.js} +100 -49
  37. package/dist/src/inspect.js.map +1 -0
  38. package/dist/{interface.d.ts → src/interface.d.ts} +8 -1
  39. package/dist/src/interface.d.ts.map +1 -0
  40. package/dist/{interface.js → src/interface.js} +5 -0
  41. package/dist/src/interface.js.map +1 -0
  42. package/dist/{sync.d.ts → src/sync.d.ts} +18 -1
  43. package/dist/src/sync.d.ts.map +1 -0
  44. package/dist/{sync.js → src/sync.js} +57 -4
  45. package/dist/src/sync.js.map +1 -0
  46. package/dist/src/utils.d.ts +3 -0
  47. package/dist/src/utils.d.ts.map +1 -0
  48. package/dist/src/utils.js +3 -0
  49. package/dist/src/utils.js.map +1 -0
  50. package/dist/test/clone.test.d.ts +2 -0
  51. package/dist/test/clone.test.d.ts.map +1 -0
  52. package/dist/test/clone.test.js +42 -0
  53. package/dist/test/clone.test.js.map +1 -0
  54. package/dist/test/commitAndSync.test.d.ts +2 -0
  55. package/dist/test/commitAndSync.test.d.ts.map +1 -0
  56. package/dist/test/commitAndSync.test.js +27 -0
  57. package/dist/test/commitAndSync.test.js.map +1 -0
  58. package/dist/test/constants.d.ts +23 -0
  59. package/dist/test/constants.d.ts.map +1 -0
  60. package/dist/test/constants.js +51 -0
  61. package/dist/test/constants.js.map +1 -0
  62. package/dist/test/constants.test.d.ts +2 -0
  63. package/dist/test/constants.test.d.ts.map +1 -0
  64. package/dist/test/constants.test.js +7 -0
  65. package/dist/test/constants.test.js.map +1 -0
  66. package/dist/test/initGit.test.d.ts +2 -0
  67. package/dist/test/initGit.test.d.ts.map +1 -0
  68. package/dist/test/initGit.test.js +90 -0
  69. package/dist/test/initGit.test.js.map +1 -0
  70. package/dist/test/inspect.test.d.ts +2 -0
  71. package/dist/test/inspect.test.d.ts.map +1 -0
  72. package/dist/test/inspect.test.js +224 -0
  73. package/dist/test/inspect.test.js.map +1 -0
  74. package/dist/test/jest.setup.d.ts +2 -0
  75. package/dist/test/jest.setup.d.ts.map +1 -0
  76. package/dist/test/jest.setup.js +30 -0
  77. package/dist/test/jest.setup.js.map +1 -0
  78. package/dist/test/sync.test.d.ts +2 -0
  79. package/dist/test/sync.test.d.ts.map +1 -0
  80. package/dist/test/sync.test.js +75 -0
  81. package/dist/test/sync.test.js.map +1 -0
  82. package/dist/test/utils.d.ts +5 -0
  83. package/dist/test/utils.d.ts.map +1 -0
  84. package/dist/test/utils.js +38 -0
  85. package/dist/test/utils.js.map +1 -0
  86. package/package.json +24 -17
  87. package/dist/credential.d.ts.map +0 -1
  88. package/dist/credential.js.map +0 -1
  89. package/dist/defaultGitInfo.d.ts.map +0 -1
  90. package/dist/defaultGitInfo.js.map +0 -1
  91. package/dist/errors.d.ts.map +0 -1
  92. package/dist/errors.js.map +0 -1
  93. package/dist/index.d.ts +0 -46
  94. package/dist/index.d.ts.map +0 -1
  95. package/dist/index.js +0 -234
  96. package/dist/index.js.map +0 -1
  97. package/dist/inspect.d.ts.map +0 -1
  98. package/dist/inspect.js.map +0 -1
  99. package/dist/interface.d.ts.map +0 -1
  100. package/dist/interface.js.map +0 -1
  101. package/dist/sync.d.ts.map +0 -1
  102. package/dist/sync.js.map +0 -1
package/README.md CHANGED
@@ -74,6 +74,7 @@ try {
74
74
  logger.notice(this.translateMessage(message), { handler: WikiChannel.syncProgress, callerFunction: 'commitAndSync', ...context });
75
75
  },
76
76
  },
77
+ filesToIgnore,
77
78
  });
78
79
  } catch (error) {
79
80
  this.translateErrorMessage(error);
@@ -110,7 +111,7 @@ try {
110
111
  Get modified files and modify type in a folder
111
112
 
112
113
  ```ts
113
- await getModifiedFileList(wikiFolderPath)
114
+ await getModifiedFileList(wikiFolderPath);
114
115
  ```
115
116
 
116
117
  ### getRemoteUrl
@@ -119,7 +120,7 @@ Inspect git's remote url from folder's .git config
119
120
 
120
121
  ```ts
121
122
  export async function credentialOff(directory: string, remoteUrl?: string): Promise<void> {
122
- const githubRepoUrl = remoteUrl ?? await getRemoteUrl(directory);
123
+ const githubRepoUrl = remoteUrl ?? (await getRemoteUrl(directory));
123
124
  const gitUrlWithOutCredential = getGitUrlWithOutCredential(githubRepoUrl);
124
125
  await GitProcess.exec(['remote', 'set-url', 'origin', gitUrlWithOutCredential], directory);
125
126
  }
@@ -0,0 +1,13 @@
1
+ import { IGitUserInfos, ILogger } from './interface';
2
+ import { defaultGitInfo as defaultDefaultGitInfo } from './defaultGitInfo';
3
+ export declare function clone(options: {
4
+ /** wiki folder path, can be relative, should exist before function call */
5
+ dir: string;
6
+ /** the storage service url we are sync to, for example your github repo url */
7
+ remoteUrl?: string;
8
+ /** user info used in the commit message */
9
+ userInfo?: IGitUserInfos;
10
+ logger?: ILogger;
11
+ defaultGitInfo?: typeof defaultDefaultGitInfo;
12
+ }): Promise<void>;
13
+ //# sourceMappingURL=clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/clone.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAW,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAG3E,wBAAsB,KAAK,CAAC,OAAO,EAAE;IACnC,2EAA2E;IAC3E,GAAG,EAAE,MAAM,CAAC;IACZ,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,qBAAqB,CAAC;CAC/C,GAAG,OAAO,CAAC,IAAI,CAAC,CAqDhB"}
@@ -0,0 +1,55 @@
1
+ import { GitProcess } from 'dugite';
2
+ import { truncate } from 'lodash';
3
+ import { credentialOn, credentialOff } from './credential';
4
+ import { SyncParameterMissingError, GitPullPushError } from './errors';
5
+ import { getRemoteName } from './inspect';
6
+ import { GitStep } from './interface';
7
+ import { defaultGitInfo as defaultDefaultGitInfo } from './defaultGitInfo';
8
+ import { initGitWithBranch } from './init';
9
+ export async function clone(options) {
10
+ const { dir, remoteUrl, userInfo, logger, defaultGitInfo = defaultDefaultGitInfo } = options;
11
+ const { gitUserName, branch } = userInfo ?? defaultGitInfo;
12
+ const { accessToken } = userInfo ?? {};
13
+ if (accessToken === '' || accessToken === undefined) {
14
+ throw new SyncParameterMissingError('accessToken');
15
+ }
16
+ if (remoteUrl === '' || remoteUrl === undefined) {
17
+ throw new SyncParameterMissingError('remoteUrl');
18
+ }
19
+ const logProgress = (step) => logger?.info(step, {
20
+ functionName: 'clone',
21
+ step,
22
+ dir,
23
+ remoteUrl,
24
+ });
25
+ const logDebug = (message, step) => logger?.debug(message, {
26
+ functionName: 'clone',
27
+ step,
28
+ dir,
29
+ remoteUrl,
30
+ });
31
+ logProgress(GitStep.PrepareCloneOnlineWiki);
32
+ logDebug(JSON.stringify({
33
+ remoteUrl,
34
+ gitUserName,
35
+ accessToken: truncate(accessToken, {
36
+ length: 24,
37
+ }),
38
+ }), GitStep.PrepareCloneOnlineWiki);
39
+ logDebug(`Running git init for clone in dir ${dir}`, GitStep.PrepareCloneOnlineWiki);
40
+ await initGitWithBranch(dir, branch, { initialCommit: false });
41
+ const remoteName = await getRemoteName(dir, branch);
42
+ logDebug(`Successfully Running git init for clone in dir ${dir}`, GitStep.PrepareCloneOnlineWiki);
43
+ logProgress(GitStep.StartConfiguringGithubRemoteRepository);
44
+ await credentialOn(dir, remoteUrl, gitUserName, accessToken, remoteName);
45
+ logProgress(GitStep.StartFetchingFromGithubRemote);
46
+ const { stderr: pullStdError, exitCode } = await GitProcess.exec(['pull', remoteName, `${branch}:${branch}`], dir);
47
+ await credentialOff(dir, remoteName, remoteUrl);
48
+ if (exitCode !== 0) {
49
+ throw new GitPullPushError(options, pullStdError);
50
+ }
51
+ else {
52
+ logProgress(GitStep.SynchronizationFinish);
53
+ }
54
+ }
55
+ //# sourceMappingURL=clone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.js","sourceRoot":"","sources":["../../src/clone.ts"],"names":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OAAO,CAAC,qBAAqB,CAAC,CAAC;KAC5C;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { IGitUserInfos, ILogger } from './interface';
2
+ import { defaultGitInfo as defaultDefaultGitInfo } from './defaultGitInfo';
3
+ export interface ICommitAndSyncOptions {
4
+ /** wiki folder path, can be relative */
5
+ dir: string;
6
+ /** the storage service url we are sync to, for example your github repo url */
7
+ remoteUrl: string;
8
+ /** user info used in the commit message */
9
+ userInfo: IGitUserInfos;
10
+ /** the commit message */
11
+ commitMessage?: string;
12
+ logger?: ILogger;
13
+ defaultGitInfo?: typeof defaultDefaultGitInfo;
14
+ /** if you want to use a dynamic .gitignore, you can passing an array contains filepaths that want to ignore */
15
+ filesToIgnore?: string[];
16
+ }
17
+ /**
18
+ * `git add .` + `git commit` + `git rebase` or something that can sync bi-directional
19
+ */
20
+ export declare function commitAndSync(options: ICommitAndSyncOptions): Promise<void>;
21
+ //# sourceMappingURL=commitAndSync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commitAndSync.d.ts","sourceRoot":"","sources":["../../src/commitAndSync.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAW,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAG3E,MAAM,WAAW,qBAAqB;IACpC,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,+EAA+E;IAC/E,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,QAAQ,EAAE,aAAa,CAAC;IACxB,yBAAyB;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,qBAAqB,CAAC;IAC9C,+GAA+G;IAC/G,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AACD;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+IjF"}
@@ -0,0 +1,143 @@
1
+ import { GitProcess } from 'dugite';
2
+ import { credentialOn, credentialOff } from './credential';
3
+ import { SyncParameterMissingError, GitPullPushError, CantSyncGitNotInitializedError } from './errors';
4
+ import { assumeSync, getDefaultBranchName, getGitRepositoryState, getRemoteName, getSyncState, haveLocalChanges } from './inspect';
5
+ import { GitStep } from './interface';
6
+ import { defaultGitInfo as defaultDefaultGitInfo } from './defaultGitInfo';
7
+ import { commitFiles, continueRebase, mergeUpstream, pushUpstream } from './sync';
8
+ /**
9
+ * `git add .` + `git commit` + `git rebase` or something that can sync bi-directional
10
+ */
11
+ export async function commitAndSync(options) {
12
+ const { dir, remoteUrl, commitMessage = 'Updated with Git-Sync', userInfo, logger, defaultGitInfo = defaultDefaultGitInfo, filesToIgnore } = options;
13
+ const { gitUserName, email, branch } = userInfo ?? defaultGitInfo;
14
+ const { accessToken } = userInfo ?? {};
15
+ if (accessToken === '' || accessToken === undefined) {
16
+ throw new SyncParameterMissingError('accessToken');
17
+ }
18
+ if (remoteUrl === '' || remoteUrl === undefined) {
19
+ throw new SyncParameterMissingError('remoteUrl');
20
+ }
21
+ const defaultBranchName = (await getDefaultBranchName(dir)) ?? branch;
22
+ const remoteName = await getRemoteName(dir, defaultBranchName);
23
+ const logProgress = (step) => logger?.info?.(step, {
24
+ functionName: 'commitAndSync',
25
+ step,
26
+ dir,
27
+ remoteUrl,
28
+ branch: defaultBranchName,
29
+ });
30
+ const logDebug = (message, step) => logger?.debug?.(message, {
31
+ functionName: 'commitAndSync',
32
+ step,
33
+ dir,
34
+ remoteUrl,
35
+ branch: defaultBranchName,
36
+ });
37
+ const logWarn = (message, step) => logger?.warn?.(message, {
38
+ functionName: 'commitAndSync',
39
+ step,
40
+ dir,
41
+ remoteUrl,
42
+ branch: defaultBranchName,
43
+ });
44
+ // preflight check
45
+ const repoStartingState = await getGitRepositoryState(dir, logger);
46
+ if (repoStartingState.length === 0 || repoStartingState === '|DIRTY') {
47
+ logProgress(GitStep.PrepareSync);
48
+ logDebug(`${dir} repoStartingState: ${repoStartingState}, ${gitUserName} <${email ?? defaultGitInfo.email}>`, GitStep.PrepareSync);
49
+ }
50
+ else if (repoStartingState === 'NOGIT') {
51
+ throw new CantSyncGitNotInitializedError(dir);
52
+ }
53
+ else {
54
+ // we may be in middle of a rebase, try fix that
55
+ await continueRebase(dir, gitUserName, email ?? defaultGitInfo.email, logger, repoStartingState);
56
+ }
57
+ if (await haveLocalChanges(dir)) {
58
+ logProgress(GitStep.HaveThingsToCommit);
59
+ logDebug(commitMessage, GitStep.HaveThingsToCommit);
60
+ const { exitCode: commitExitCode, stderr: commitStdError } = await commitFiles(dir, gitUserName, email ?? defaultGitInfo.email, commitMessage, filesToIgnore);
61
+ if (commitExitCode !== 0) {
62
+ logWarn(`commit failed ${commitStdError}`, GitStep.CommitComplete);
63
+ }
64
+ logProgress(GitStep.CommitComplete);
65
+ }
66
+ logProgress(GitStep.PreparingUserInfo);
67
+ await credentialOn(dir, remoteUrl, gitUserName, accessToken, remoteName);
68
+ logProgress(GitStep.FetchingData);
69
+ await GitProcess.exec(['fetch', remoteName, defaultBranchName], dir);
70
+ let exitCode = 0;
71
+ let stderr;
72
+ const syncStateAfterCommit = await getSyncState(dir, defaultBranchName, remoteName, logger);
73
+ switch (syncStateAfterCommit) {
74
+ case 'equal': {
75
+ logProgress(GitStep.NoNeedToSync);
76
+ await credentialOff(dir, remoteUrl);
77
+ return;
78
+ }
79
+ case 'noUpstreamOrBareUpstream': {
80
+ logProgress(GitStep.NoUpstreamCantPush);
81
+ // try push, if success, means it is bare, otherwise, it is no upstream
82
+ try {
83
+ await pushUpstream(dir, defaultBranchName, remoteName, logger);
84
+ break;
85
+ }
86
+ catch (error) {
87
+ logWarn(`${JSON.stringify({ dir, remoteUrl, userInfo })}, remoteUrl may be not valid, noUpstreamOrBareUpstream after credentialOn`, GitStep.NoUpstreamCantPush);
88
+ throw error;
89
+ }
90
+ }
91
+ case 'ahead': {
92
+ logProgress(GitStep.LocalAheadStartUpload);
93
+ await pushUpstream(dir, defaultBranchName, remoteName, logger);
94
+ break;
95
+ }
96
+ case 'behind': {
97
+ logProgress(GitStep.LocalStateBehindSync);
98
+ await mergeUpstream(dir, defaultBranchName, remoteName, logger);
99
+ break;
100
+ }
101
+ case 'diverged': {
102
+ logProgress(GitStep.LocalStateDivergeRebase);
103
+ ({ exitCode, stderr } = await GitProcess.exec(['rebase', `${remoteName}/${defaultBranchName}`], dir));
104
+ logProgress(GitStep.RebaseResultChecking);
105
+ if (exitCode !== 0) {
106
+ logWarn(`exitCode: ${exitCode}, stderr of git rebase: ${stderr}`, GitStep.RebaseResultChecking);
107
+ }
108
+ if (exitCode === 0 &&
109
+ (await getGitRepositoryState(dir, logger)).length === 0 &&
110
+ (await getSyncState(dir, defaultBranchName, remoteName, logger)) === 'ahead') {
111
+ logProgress(GitStep.RebaseSucceed);
112
+ }
113
+ else {
114
+ await continueRebase(dir, gitUserName, email ?? defaultGitInfo.email, logger);
115
+ logProgress(GitStep.RebaseConflictNeedsResolve);
116
+ }
117
+ await pushUpstream(dir, defaultBranchName, remoteName, logger);
118
+ break;
119
+ }
120
+ default: {
121
+ logProgress(GitStep.SyncFailedAlgorithmWrong);
122
+ }
123
+ }
124
+ await credentialOff(dir, remoteUrl);
125
+ if (exitCode === 0) {
126
+ logProgress(GitStep.PerformLastCheckBeforeSynchronizationFinish);
127
+ await assumeSync(dir, defaultBranchName, remoteName, logger);
128
+ logProgress(GitStep.SynchronizationFinish);
129
+ }
130
+ else {
131
+ switch (exitCode) {
132
+ // "message":"exitCode: 128, stderr of git push: fatal: unable to access 'https://github.com/tiddly-gittly/TiddlyWiki-Chinese-Tutorial.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 \n"
133
+ case 128: {
134
+ throw new GitPullPushError(options, stderr ?? '');
135
+ }
136
+ // TODO: handle auth expire and throw here
137
+ default: {
138
+ throw new GitPullPushError(options, stderr ?? '');
139
+ }
140
+ }
141
+ }
142
+ }
143
+ //# sourceMappingURL=commitAndSync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commitAndSync.js","sourceRoot":"","sources":["../../src/commitAndSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AACvG,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACnI,OAAO,EAA0B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAgBlF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA8B;IAChE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,aAAa,GAAG,uBAAuB,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,GAAG,qBAAqB,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IACrJ,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,QAAQ,IAAI,cAAc,CAAC;IAClE,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,IAAI,EAAE,CAAC;IAEvC,IAAI,WAAW,KAAK,EAAE,IAAI,WAAW,KAAK,SAAS,EAAE;QACnD,MAAM,IAAI,yBAAyB,CAAC,aAAa,CAAC,CAAC;KACpD;IACD,IAAI,SAAS,KAAK,EAAE,IAAI,SAAS,KAAK,SAAS,EAAE;QA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,CAAC,OAAO,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC;aACnD;SACF;KACF;AACH,CAAC"}
@@ -1,15 +1,16 @@
1
+ export declare const getGitUrlWithCredential: (rawUrl: string, username: string, accessToken: string) => string;
1
2
  /**
2
3
  * Add remote with credential
3
4
  * @param {string} directory
4
5
  * @param {string} remoteUrl
5
6
  * @param {{ login: string, email: string, accessToken: string }} userInfo
6
7
  */
7
- export declare function credentialOn(directory: string, remoteUrl: string, userName: string, accessToken: string): Promise<void>;
8
+ export declare function credentialOn(directory: string, remoteUrl: string, userName: string, accessToken: string, remoteName: string): Promise<void>;
8
9
  /**
9
10
  * Add remote without credential
10
11
  * @param {string} directory
11
12
  * @param {string} githubRepoUrl
12
13
  * @param {{ login: string, email: string, accessToken: string }} userInfo
13
14
  */
14
- export declare function credentialOff(directory: string, remoteUrl?: string): Promise<void>;
15
+ export declare function credentialOff(directory: string, remoteName: string, remoteUrl?: string): Promise<void>;
15
16
  //# sourceMappingURL=credential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential.d.ts","sourceRoot":"","sources":["../../src/credential.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB,WAAY,MAAM,YAAY,MAAM,eAAe,MAAM,KAAG,MACkB,CAAC;AAGnH;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjJ;AACD;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI5G"}
@@ -1,7 +1,7 @@
1
1
  import { trim } from 'lodash';
2
2
  import { GitProcess } from 'dugite';
3
3
  import { getRemoteUrl } from './inspect';
4
- const getGitUrlWithCredential = (rawUrl, username, accessToken) => trim(`${rawUrl}.git`.replace(/\n/g, '').replace('https://github.com/', `https://${username}:${accessToken}@github.com/`));
4
+ export const getGitUrlWithCredential = (rawUrl, username, accessToken) => trim(rawUrl.replace(/\n/g, '').replace('https://github.com/', `https://${username}:${accessToken}@github.com/`));
5
5
  const getGitUrlWithOutCredential = (urlWithCredential) => trim(urlWithCredential.replace(/.+@/, 'https://'));
6
6
  /**
7
7
  * Add remote with credential
@@ -9,10 +9,10 @@ const getGitUrlWithOutCredential = (urlWithCredential) => trim(urlWithCredential
9
9
  * @param {string} remoteUrl
10
10
  * @param {{ login: string, email: string, accessToken: string }} userInfo
11
11
  */
12
- export async function credentialOn(directory, remoteUrl, userName, accessToken) {
12
+ export async function credentialOn(directory, remoteUrl, userName, accessToken, remoteName) {
13
13
  const gitUrlWithCredential = getGitUrlWithCredential(remoteUrl, userName, accessToken);
14
- await GitProcess.exec(['remote', 'add', 'origin', gitUrlWithCredential], directory);
15
- await GitProcess.exec(['remote', 'set-url', 'origin', gitUrlWithCredential], directory);
14
+ await GitProcess.exec(['remote', 'add', remoteName, gitUrlWithCredential], directory);
15
+ await GitProcess.exec(['remote', 'set-url', remoteName, gitUrlWithCredential], directory);
16
16
  }
17
17
  /**
18
18
  * Add remote without credential
@@ -20,9 +20,9 @@ export async function credentialOn(directory, remoteUrl, userName, accessToken)
20
20
  * @param {string} githubRepoUrl
21
21
  * @param {{ login: string, email: string, accessToken: string }} userInfo
22
22
  */
23
- export async function credentialOff(directory, remoteUrl) {
24
- const githubRepoUrl = remoteUrl ?? (await getRemoteUrl(directory));
23
+ export async function credentialOff(directory, remoteName, remoteUrl) {
24
+ const githubRepoUrl = remoteUrl ?? (await getRemoteUrl(directory, remoteName));
25
25
  const gitUrlWithOutCredential = getGitUrlWithOutCredential(githubRepoUrl);
26
- await GitProcess.exec(['remote', 'set-url', 'origin', gitUrlWithOutCredential], directory);
26
+ await GitProcess.exec(['remote', 'set-url', remoteName, gitUrlWithOutCredential], directory);
27
27
  }
28
28
  //# sourceMappingURL=credential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential.js","sourceRoot":"","sources":["../../src/credential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAE,WAAmB,EAAU,EAAE,CACvG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,WAAW,QAAQ,IAAI,WAAW,cAAc,CAAC,CAAC,CAAC;AACnH,MAAM,0BAA0B,GAAG,CAAC,iBAAyB,EAAU,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;AAE7H;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,SAAiB,EAAE,SAAiB,EAAE,QAAgB,EAAE,WAAmB,EAAE,UAAkB;IAChI,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IACvF,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACtF,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;AAC5F,CAAC;AACD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,SAAiB,EAAE,UAAkB,EAAE,SAAkB;IAC3F,MAAM,aAAa,GAAG,SAAS,IAAI,CAAC,MAAM,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAC/E,MAAM,uBAAuB,GAAG,0BAA0B,CAAC,aAAa,CAAC,CAAC;IAC1E,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,uBAAuB,CAAC,EAAE,SAAS,CAAC,CAAC;AAC/F,CAAC"}
@@ -1,5 +1,7 @@
1
1
  export declare const defaultGitInfo: {
2
2
  email: string;
3
3
  gitUserName: string;
4
+ branch: string;
5
+ remote: string;
4
6
  };
5
7
  //# sourceMappingURL=defaultGitInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultGitInfo.d.ts","sourceRoot":"","sources":["../../src/defaultGitInfo.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;CAK1B,CAAC"}
@@ -1,5 +1,7 @@
1
1
  export const defaultGitInfo = {
2
2
  email: 'gitsync@gmail.com',
3
3
  gitUserName: 'gitsync',
4
+ branch: 'main',
5
+ remote: 'origin',
4
6
  };
5
7
  //# sourceMappingURL=defaultGitInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultGitInfo.js","sourceRoot":"","sources":["../../src/defaultGitInfo.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,SAAS;IACtB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,QAAQ;CACjB,CAAC"}
@@ -1,6 +1,7 @@
1
+ import { SyncState } from './inspect';
1
2
  import { IGitUserInfos, IGitUserInfosWithoutToken } from './interface';
2
3
  export declare class AssumeSyncError extends Error {
3
- constructor(extraMessage?: string);
4
+ constructor(state: SyncState, extraMessage?: string);
4
5
  }
5
6
  export declare class SyncParameterMissingError extends Error {
6
7
  /** the missing parameterName */
@@ -13,8 +14,11 @@ export declare class GitPullPushError extends Error {
13
14
  dir: string;
14
15
  /** the storage service url we are sync to, for example your github repo url */
15
16
  remoteUrl?: string;
17
+ /** for example, origin */
18
+ remote?: string;
16
19
  /** user info used in the commit message */
17
20
  userInfo?: IGitUserInfos | IGitUserInfosWithoutToken;
21
+ branch?: string;
18
22
  }, extraMessages: string);
19
23
  }
20
24
  export declare class CantSyncGitNotInitializedError extends Error {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAEvE,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,KAAK,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,MAAM;CAQpD;AACD,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;gBACV,aAAa,SAAgB;CAO1C;AAED,qBAAa,gBAAiB,SAAQ,KAAK;gBAEvC,aAAa,EAAE;QACb,wCAAwC;QACxC,GAAG,EAAE,MAAM,CAAC;QACZ,+EAA+E;QAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,0BAA0B;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,2CAA2C;QAC3C,QAAQ,CAAC,EAAE,aAAa,GAAG,yBAAyB,CAAC;QACrD,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,EACD,aAAa,EAAE,MAAM;CAexB;AAED,qBAAa,8BAA+B,SAAQ,KAAK;IACvD,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;gBACN,SAAS,EAAE,MAAM;CAO9B;AAED,qBAAa,2BAA4B,SAAQ,KAAK;;CAOrD;AAED,qBAAa,sCAAuC,SAAQ,KAAK;IAC/D,YAAY,EAAE,MAAM,CAAC;gBACT,YAAY,EAAE,MAAM;CAOjC"}
@@ -4,11 +4,11 @@
4
4
  */
5
5
  import { truncate } from 'lodash';
6
6
  export class AssumeSyncError extends Error {
7
- constructor(extraMessage) {
7
+ constructor(state, extraMessage) {
8
8
  super(extraMessage);
9
9
  Object.setPrototypeOf(this, AssumeSyncError.prototype);
10
10
  this.name = 'AssumeSyncError';
11
- this.message = `E-1 In this state, git should have been sync with the remote, but it is not, this is caused by procedural bug in the git-sync-js. ${extraMessage ?? ''}`;
11
+ this.message = `E-1 In this state, git should have been sync with the remote, but it is "${state}", this is caused by procedural bug in the git-sync-js. ${extraMessage ?? ''}`;
12
12
  }
13
13
  }
14
14
  export class SyncParameterMissingError extends Error {
@@ -19,7 +19,7 @@ export class SyncParameterMissingError extends Error {
19
19
  Object.setPrototypeOf(this, SyncParameterMissingError.prototype);
20
20
  this.name = 'SyncParameterMissingError';
21
21
  this.parameterName = parameterName;
22
- this.message = `E-2 We need ${parameterName} to sync to the cloud, you should pass ${parameterName} as parameters in userInfo.`;
22
+ this.message = `E-2 We need ${parameterName} to sync to the cloud, you should pass ${parameterName} as parameters in options.`;
23
23
  }
24
24
  }
25
25
  export class GitPullPushError extends Error {
@@ -30,12 +30,12 @@ export class GitPullPushError extends Error {
30
30
  this.message = `E-3 failed to config git to successfully pull from or push to remote with configuration ${JSON.stringify({
31
31
  ...configuration,
32
32
  userInfo: {
33
- ...(configuration.userInfo ?? {}),
33
+ ...configuration.userInfo,
34
34
  accessToken: truncate(configuration?.userInfo?.accessToken, {
35
35
  length: 24,
36
36
  }),
37
37
  },
38
- })}.\n${extraMessages}`;
38
+ })}.\nerrorMessages: ${extraMessages}`;
39
39
  }
40
40
  }
41
41
  export class CantSyncGitNotInitializedError extends Error {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIlC,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY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gD;IAChD,SAAS,CAAS;IAClB,YAAY,SAAiB;QAC3B,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,8BAA8B,CAAC,SAAS,CAAC,CAAC;QACtE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,6GAA6G,SAAS,EAAE,CAAC;IAC1I,CAAC;CACF;AAED,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD;QACE,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,6GAA6G,CAAC;IAC/H,CAAC;CACF;AAED,MAAM,OAAO,sCAAuC,SAAQ,KAAK;IAC/D,YAAY,CAAS;IACrB,YAAY,YAAoB;QAC9B,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sCAAsC,CAAC,SAAS,CAAC,CAAC;QAC9E,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,wCAAwC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,qYAAqY,YAAY,EAAE,CAAC;IACra,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ /** primary functions */
2
+ export * from './initGit';
3
+ export * from './commitAndSync';
4
+ export * from './clone';
5
+ /** utils */
6
+ export * from './interface';
7
+ export * from './defaultGitInfo';
8
+ export * from './errors';
9
+ export * from './credential';
10
+ export * from './inspect';
11
+ export * from './sync';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,YAAY;AACZ,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,12 @@
1
+ /** primary functions */
2
+ export * from './initGit';
3
+ export * from './commitAndSync';
4
+ export * from './clone';
5
+ /** utils */
6
+ export * from './interface';
7
+ export * from './defaultGitInfo';
8
+ export * from './errors';
9
+ export * from './credential';
10
+ export * from './inspect';
11
+ export * from './sync';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,YAAY;AACZ,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,25 @@
1
+ export interface IGitInitOptions {
2
+ /**
3
+ * Whether create a bare repo, useful as an upstream repo
4
+ */
5
+ bare?: boolean;
6
+ /**
7
+ * Default to true, to try to fix https://stackoverflow.com/questions/12267912/git-error-fatal-ambiguous-argument-head-unknown-revision-or-path-not-in-the
8
+ *
9
+ * Following techniques are not working:
10
+ *
11
+ * ```js
12
+ * await GitProcess.exec(['symbolic-ref', 'HEAD', `refs/heads/${branch}`], dir);
13
+ * await GitProcess.exec(['checkout', `-b`, branch], dir);
14
+ * ```
15
+ *
16
+ * This works:
17
+ * https://stackoverflow.com/a/51527691/4617295
18
+ */
19
+ initialCommit?: boolean;
20
+ }
21
+ /**
22
+ * Init and immediately checkout the branch, other wise the branch will be HEAD, which is annoying in the later steps
23
+ */
24
+ export declare function initGitWithBranch(dir: string, branch?: string, options?: IGitInitOptions): Promise<void>;
25
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,SAAwB,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAY7H"}
@@ -0,0 +1,22 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ /* eslint-disable unicorn/prevent-abbreviations */
4
+ import { GitProcess } from 'dugite';
5
+ import { defaultGitInfo } from './defaultGitInfo';
6
+ /**
7
+ * Init and immediately checkout the branch, other wise the branch will be HEAD, which is annoying in the later steps
8
+ */
9
+ export async function initGitWithBranch(dir, branch = defaultGitInfo.branch, options) {
10
+ if (options?.bare === true) {
11
+ const bareGitPath = path.join(dir, '.git');
12
+ await fs.mkdirp(bareGitPath);
13
+ await GitProcess.exec(['init', `--initial-branch=${branch}`, '--bare'], bareGitPath);
14
+ }
15
+ else {
16
+ await GitProcess.exec(['init', `--initial-branch=${branch}`], dir);
17
+ }
18
+ if (options?.initialCommit !== false) {
19
+ await GitProcess.exec(['commit', `--allow-empty`, '-n', '-m', 'Initial commit when init a new git.'], dir);
20
+ }
21
+ }
22
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,kDAAkD;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAwBlD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAW,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,OAAyB;IAC5G,IAAI,OAAO,EAAE,IAAI,KAAK,IAAI,EAAE;QAC1B,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC3C,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC7B,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,oBAAoB,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;KACtF;SAAM;QACL,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,oBAAoB,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;KACpE;IAED,IAAI,OAAO,EAAE,aAAa,KAAK,KAAK,EAAE;QACpC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,qCAAqC,CAAC,EAAE,GAAG,CAAC,CAAC;KAC5G;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { IGitUserInfosWithoutToken, IGitUserInfos, ILogger } from './interface';
2
+ import { defaultGitInfo as defaultDefaultGitInfo } from './defaultGitInfo';
3
+ export declare type IInitGitOptions = IInitGitOptionsSyncImmediately | IInitGitOptionsNotSync;
4
+ export interface IInitGitOptionsSyncImmediately {
5
+ /** wiki folder path, can be relative */
6
+ dir: string;
7
+ /** should we sync after git init? */
8
+ syncImmediately: true;
9
+ /** only required if syncImmediately is true, the storage service url we are sync to, for example your github repo url */
10
+ remoteUrl: string;
11
+ /** user info used in the commit message */
12
+ userInfo: IGitUserInfos;
13
+ logger?: ILogger;
14
+ defaultGitInfo?: typeof defaultDefaultGitInfo;
15
+ }
16
+ export interface IInitGitOptionsNotSync {
17
+ /** wiki folder path, can be relative */
18
+ dir: string;
19
+ /** should we sync after git init? */
20
+ syncImmediately?: false;
21
+ userInfo?: IGitUserInfosWithoutToken | IGitUserInfos;
22
+ logger?: ILogger;
23
+ defaultGitInfo?: typeof defaultDefaultGitInfo;
24
+ }
25
+ export declare function initGit(options: IInitGitOptions): Promise<void>;
26
+ //# sourceMappingURL=initGit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initGit.d.ts","sourceRoot":"","sources":["../../src/initGit.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,OAAO,EAAW,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAI3E,oBAAY,eAAe,GAAG,8BAA8B,GAAG,sBAAsB,CAAC;AACtF,MAAM,WAAW,8BAA8B;IAC7C,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,eAAe,EAAE,IAAI,CAAC;IACtB,yHAAyH;IACzH,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,qBAAqB,CAAC;CAC/C;AACD,MAAM,WAAW,sBAAsB;IACrC,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,eAAe,CAAC,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,EAAE,yBAAyB,GAAG,aAAa,CAAC;IACrD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,qBAAqB,CAAC;CAC/C;AAED,wBAAsB,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCrE"}
@@ -0,0 +1,40 @@
1
+ import { truncate } from 'lodash';
2
+ import { SyncParameterMissingError } from './errors';
3
+ import { initGitWithBranch } from './init';
4
+ import { GitStep } from './interface';
5
+ import { defaultGitInfo as defaultDefaultGitInfo } from './defaultGitInfo';
6
+ import { commitFiles } from './sync';
7
+ import { commitAndSync } from './commitAndSync';
8
+ export async function initGit(options) {
9
+ const { dir, userInfo, syncImmediately, logger, defaultGitInfo = defaultDefaultGitInfo } = options;
10
+ const logProgress = (step) => logger?.info(step, {
11
+ functionName: 'initGit',
12
+ step,
13
+ });
14
+ const logDebug = (message, step) => logger?.debug(message, { functionName: 'initGit', step });
15
+ logProgress(GitStep.StartGitInitialization);
16
+ const { gitUserName, email, branch } = userInfo ?? defaultGitInfo;
17
+ logDebug(`Running git init in dir ${dir}`, GitStep.StartGitInitialization);
18
+ await initGitWithBranch(dir, branch);
19
+ logDebug(`Succefully Running git init in dir ${dir}`, GitStep.StartGitInitialization);
20
+ await commitFiles(dir, gitUserName, email ?? defaultGitInfo.email);
21
+ // if we are config local note git, we are done here
22
+ if (syncImmediately !== true) {
23
+ logProgress(GitStep.GitRepositoryConfigurationFinished);
24
+ return;
25
+ }
26
+ // sync to remote, start config synced note
27
+ if (userInfo === undefined || !('accessToken' in userInfo) || userInfo?.accessToken?.length === 0) {
28
+ throw new SyncParameterMissingError('accessToken');
29
+ }
30
+ const { remoteUrl } = options;
31
+ if (remoteUrl === undefined || remoteUrl.length === 0) {
32
+ throw new SyncParameterMissingError('remoteUrl');
33
+ }
34
+ logDebug(`Calling commitAndSync() from initGit() Using gitUrl ${remoteUrl} with gitUserName ${gitUserName} and accessToken ${truncate(userInfo?.accessToken, {
35
+ length: 24,
36
+ })}`, GitStep.StartConfiguringGithubRemoteRepository);
37
+ logProgress(GitStep.StartConfiguringGithubRemoteRepository);
38
+ await commitAndSync(options);
39
+ }
40
+ //# sourceMappingURL=initGit.js.map
@@ -0,0 +1 @@
1
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