@decohere/core 0.0.1-dev.116

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 (262) hide show
  1. package/commonjs/src/caching/cache-manager.js +98 -0
  2. package/commonjs/src/caching/cache.decorator.js +69 -0
  3. package/commonjs/src/caching/cache.js +6 -0
  4. package/commonjs/src/caching/index.js +23 -0
  5. package/commonjs/src/caching/invalidate-cache.decorator.js +92 -0
  6. package/commonjs/src/caching/memoize.decorator.js +36 -0
  7. package/commonjs/src/caching/node-cache-memoize.adapter.js +49 -0
  8. package/commonjs/src/cli/action.js +65 -0
  9. package/commonjs/src/cli/command.js +127 -0
  10. package/commonjs/src/cli/index.js +61 -0
  11. package/commonjs/src/cli/module.type.js +18 -0
  12. package/commonjs/src/cli/options.js +115 -0
  13. package/commonjs/src/collections/collections.js +21 -0
  14. package/commonjs/src/collections/find-duplicates.js +35 -0
  15. package/commonjs/src/collections/index.js +52 -0
  16. package/commonjs/src/collections/merge-arrays.js +34 -0
  17. package/commonjs/src/collections/sum.js +63 -0
  18. package/commonjs/src/collections/unique-objects.js +39 -0
  19. package/commonjs/src/composition/index.js +4 -0
  20. package/commonjs/src/configuration/configuration.types.js +11 -0
  21. package/commonjs/src/configuration/index.js +18 -0
  22. package/commonjs/src/diagnostics/index.js +22 -0
  23. package/commonjs/src/diagnostics/trace.js +86 -0
  24. package/commonjs/src/extensibility/decorator-factory-base.js +22 -0
  25. package/commonjs/src/extensibility/decorator-factory.js +31 -0
  26. package/commonjs/src/extensibility/extension.js +37 -0
  27. package/commonjs/src/extensibility/index.js +23 -0
  28. package/commonjs/src/extensibility/mixwith.js +36 -0
  29. package/commonjs/src/extensibility/pipeline.js +56 -0
  30. package/commonjs/src/extensibility/step.js +18 -0
  31. package/commonjs/src/interop/docker/docker.js +54 -0
  32. package/commonjs/src/interop/errors/interop.error.js +12 -0
  33. package/commonjs/src/interop/git/git.js +134 -0
  34. package/commonjs/src/interop/git/git.types.js +4 -0
  35. package/commonjs/src/interop/index.js +97 -0
  36. package/commonjs/src/interop/node/index.js +18 -0
  37. package/commonjs/src/interop/node/node.js +45 -0
  38. package/commonjs/src/interop/npm/npm.js +231 -0
  39. package/commonjs/src/interop/npm/npm.types.js +16 -0
  40. package/commonjs/src/interop/pnpm/pnpm.js +34 -0
  41. package/commonjs/src/interop/pnpm/pnpm.types.js +4 -0
  42. package/commonjs/src/interop/shell/shell.argv.js +45 -0
  43. package/commonjs/src/interop/shell/shell.js +105 -0
  44. package/commonjs/src/interop/shell/shell.types.js +4 -0
  45. package/commonjs/src/interop/types/detect-package-manager.js +71 -0
  46. package/commonjs/src/interop/types/package-manager.js +4 -0
  47. package/commonjs/src/interop/yarn/yarn.js +34 -0
  48. package/commonjs/src/interop/yarn/yarn.types.js +4 -0
  49. package/commonjs/src/io/copy-file.js +25 -0
  50. package/commonjs/src/io/delete-file.js +21 -0
  51. package/commonjs/src/io/directory-exists.js +24 -0
  52. package/commonjs/src/io/file-exists.js +19 -0
  53. package/commonjs/src/io/find-directories.js +21 -0
  54. package/commonjs/src/io/find-file.js +45 -0
  55. package/commonjs/src/io/index.js +66 -0
  56. package/commonjs/src/io/io.js +28 -0
  57. package/commonjs/src/io/read-file.js +39 -0
  58. package/commonjs/src/io/remove-dir.js +22 -0
  59. package/commonjs/src/io/types/directory.type.js +4 -0
  60. package/commonjs/src/io/types/file.js +28 -0
  61. package/commonjs/src/io/types/index.js +19 -0
  62. package/commonjs/src/io/url-to-path.js +33 -0
  63. package/commonjs/src/io/watch.js +261 -0
  64. package/commonjs/src/io/write-file.js +30 -0
  65. package/commonjs/src/objects/deep-merge.js +67 -0
  66. package/commonjs/src/objects/index.js +11 -0
  67. package/commonjs/src/reflection/index.js +20 -0
  68. package/commonjs/src/reflection/types/index.js +18 -0
  69. package/commonjs/src/reflection/types/reflection.types.js +26 -0
  70. package/commonjs/src/reflection/utilities.js +118 -0
  71. package/commonjs/src/semver/index.js +18 -0
  72. package/commonjs/src/semver/semver.js +92 -0
  73. package/commonjs/src/system/camel-case.js +13 -0
  74. package/commonjs/src/system/debounce.js +19 -0
  75. package/commonjs/src/system/decorator.js +46 -0
  76. package/commonjs/src/system/environment.js +23 -0
  77. package/commonjs/src/system/function.types.js +18 -0
  78. package/commonjs/src/system/index.js +24 -0
  79. package/commonjs/src/system/retry.decorator.js +40 -0
  80. package/commonjs/src/system/sleep.js +13 -0
  81. package/commonjs/src/system/type.utils.js +4 -0
  82. package/commonjs/src/testing/flush-promises.js +16 -0
  83. package/commonjs/src/testing/glob-with-memfs.js +22 -0
  84. package/commonjs/src/testing/index.js +22 -0
  85. package/commonjs/src/testing/memfs.js +52 -0
  86. package/commonjs/src/testing/mock-logger.js +36 -0
  87. package/commonjs/src/testing/spy-on-constructor.js +27 -0
  88. package/es6/src/caching/cache-manager.js +82 -0
  89. package/es6/src/caching/cache.decorator.js +51 -0
  90. package/es6/src/caching/cache.js +3 -0
  91. package/es6/src/caching/index.js +6 -0
  92. package/es6/src/caching/invalidate-cache.decorator.js +71 -0
  93. package/es6/src/caching/memoize.decorator.js +27 -0
  94. package/es6/src/caching/node-cache-memoize.adapter.js +37 -0
  95. package/es6/src/cli/action.js +47 -0
  96. package/es6/src/cli/command.js +106 -0
  97. package/es6/src/cli/index.js +4 -0
  98. package/es6/src/cli/module.type.js +11 -0
  99. package/es6/src/cli/options.js +76 -0
  100. package/es6/src/collections/collections.js +4 -0
  101. package/es6/src/collections/find-duplicates.js +17 -0
  102. package/es6/src/collections/index.js +1 -0
  103. package/es6/src/collections/merge-arrays.js +16 -0
  104. package/es6/src/collections/sum.js +45 -0
  105. package/es6/src/collections/unique-objects.js +21 -0
  106. package/es6/src/composition/index.js +1 -0
  107. package/es6/src/configuration/configuration.types.js +1 -0
  108. package/es6/src/configuration/index.js +1 -0
  109. package/es6/src/diagnostics/index.js +1 -0
  110. package/es6/src/diagnostics/trace.js +68 -0
  111. package/es6/src/extensibility/decorator-factory-base.js +39 -0
  112. package/es6/src/extensibility/decorator-factory.js +21 -0
  113. package/es6/src/extensibility/extension.js +27 -0
  114. package/es6/src/extensibility/index.js +6 -0
  115. package/es6/src/extensibility/mixwith.js +26 -0
  116. package/es6/src/extensibility/pipeline.js +46 -0
  117. package/es6/src/extensibility/step.js +16 -0
  118. package/es6/src/interop/docker/docker.js +44 -0
  119. package/es6/src/interop/errors/interop.error.js +2 -0
  120. package/es6/src/interop/git/git.js +124 -0
  121. package/es6/src/interop/git/git.types.js +1 -0
  122. package/es6/src/interop/index.js +21 -0
  123. package/es6/src/interop/node/index.js +1 -0
  124. package/es6/src/interop/node/node.js +35 -0
  125. package/es6/src/interop/npm/npm.js +180 -0
  126. package/es6/src/interop/npm/npm.types.js +6 -0
  127. package/es6/src/interop/pnpm/pnpm.js +24 -0
  128. package/es6/src/interop/pnpm/pnpm.types.js +1 -0
  129. package/es6/src/interop/shell/shell.argv.js +35 -0
  130. package/es6/src/interop/shell/shell.js +95 -0
  131. package/es6/src/interop/shell/shell.types.js +1 -0
  132. package/es6/src/interop/types/detect-package-manager.js +50 -0
  133. package/es6/src/interop/types/package-manager.js +1 -0
  134. package/es6/src/interop/yarn/yarn.js +24 -0
  135. package/es6/src/interop/yarn/yarn.types.js +1 -0
  136. package/es6/src/io/copy-file.js +10 -0
  137. package/es6/src/io/delete-file.js +6 -0
  138. package/es6/src/io/directory-exists.js +9 -0
  139. package/es6/src/io/file-exists.js +9 -0
  140. package/es6/src/io/find-directories.js +11 -0
  141. package/es6/src/io/find-file.js +27 -0
  142. package/es6/src/io/index.js +2 -0
  143. package/es6/src/io/io.js +11 -0
  144. package/es6/src/io/read-file.js +13 -0
  145. package/es6/src/io/remove-dir.js +7 -0
  146. package/es6/src/io/types/directory.type.js +1 -0
  147. package/es6/src/io/types/file.js +18 -0
  148. package/es6/src/io/types/index.js +2 -0
  149. package/es6/src/io/url-to-path.js +15 -0
  150. package/es6/src/io/watch.js +238 -0
  151. package/es6/src/io/write-file.js +15 -0
  152. package/es6/src/objects/deep-merge.js +57 -0
  153. package/es6/src/objects/index.js +1 -0
  154. package/es6/src/reflection/index.js +3 -0
  155. package/es6/src/reflection/types/index.js +1 -0
  156. package/es6/src/reflection/types/reflection.types.js +8 -0
  157. package/es6/src/reflection/utilities.js +74 -0
  158. package/es6/src/semver/index.js +1 -0
  159. package/es6/src/semver/semver.js +71 -0
  160. package/es6/src/system/camel-case.js +3 -0
  161. package/es6/src/system/debounce.js +9 -0
  162. package/es6/src/system/decorator.js +30 -0
  163. package/es6/src/system/environment.js +5 -0
  164. package/es6/src/system/function.types.js +26 -0
  165. package/es6/src/system/index.js +7 -0
  166. package/es6/src/system/retry.decorator.js +30 -0
  167. package/es6/src/system/sleep.js +3 -0
  168. package/es6/src/system/type.utils.js +1 -0
  169. package/es6/src/testing/flush-promises.js +6 -0
  170. package/es6/src/testing/glob-with-memfs.js +20 -0
  171. package/es6/src/testing/index.js +5 -0
  172. package/es6/src/testing/memfs.js +25 -0
  173. package/es6/src/testing/mock-logger.js +26 -0
  174. package/es6/src/testing/spy-on-constructor.js +31 -0
  175. package/package.json +106 -0
  176. package/types/src/caching/cache-manager.d.ts +59 -0
  177. package/types/src/caching/cache.d.ts +11 -0
  178. package/types/src/caching/cache.decorator.d.ts +18 -0
  179. package/types/src/caching/index.d.ts +6 -0
  180. package/types/src/caching/invalidate-cache.decorator.d.ts +17 -0
  181. package/types/src/caching/memoize.decorator.d.ts +16 -0
  182. package/types/src/caching/node-cache-memoize.adapter.d.ts +22 -0
  183. package/types/src/cli/action.d.ts +36 -0
  184. package/types/src/cli/command.d.ts +34 -0
  185. package/types/src/cli/index.d.ts +7 -0
  186. package/types/src/cli/module.type.d.ts +36 -0
  187. package/types/src/cli/options.d.ts +28 -0
  188. package/types/src/collections/collections.d.ts +4 -0
  189. package/types/src/collections/find-duplicates.d.ts +2 -0
  190. package/types/src/collections/index.d.ts +1 -0
  191. package/types/src/collections/merge-arrays.d.ts +2 -0
  192. package/types/src/collections/sum.d.ts +4 -0
  193. package/types/src/collections/unique-objects.d.ts +2 -0
  194. package/types/src/composition/index.d.ts +37 -0
  195. package/types/src/configuration/configuration.types.d.ts +10 -0
  196. package/types/src/configuration/index.d.ts +1 -0
  197. package/types/src/diagnostics/index.d.ts +1 -0
  198. package/types/src/diagnostics/trace.d.ts +10 -0
  199. package/types/src/extensibility/decorator-factory-base.d.ts +39 -0
  200. package/types/src/extensibility/decorator-factory.d.ts +19 -0
  201. package/types/src/extensibility/extension.d.ts +9 -0
  202. package/types/src/extensibility/index.d.ts +6 -0
  203. package/types/src/extensibility/mixwith.d.ts +6 -0
  204. package/types/src/extensibility/pipeline.d.ts +12 -0
  205. package/types/src/extensibility/step.d.ts +16 -0
  206. package/types/src/interop/docker/docker.d.ts +19 -0
  207. package/types/src/interop/errors/interop.error.d.ts +2 -0
  208. package/types/src/interop/git/git.d.ts +16 -0
  209. package/types/src/interop/git/git.types.d.ts +14 -0
  210. package/types/src/interop/index.d.ts +14 -0
  211. package/types/src/interop/node/index.d.ts +1 -0
  212. package/types/src/interop/node/node.d.ts +5 -0
  213. package/types/src/interop/npm/npm.d.ts +29 -0
  214. package/types/src/interop/npm/npm.types.d.ts +24 -0
  215. package/types/src/interop/pnpm/pnpm.d.ts +9 -0
  216. package/types/src/interop/pnpm/pnpm.types.d.ts +3 -0
  217. package/types/src/interop/shell/shell.argv.d.ts +5 -0
  218. package/types/src/interop/shell/shell.d.ts +6 -0
  219. package/types/src/interop/shell/shell.types.d.ts +9 -0
  220. package/types/src/interop/types/detect-package-manager.d.ts +4 -0
  221. package/types/src/interop/types/package-manager.d.ts +10 -0
  222. package/types/src/interop/yarn/yarn.d.ts +9 -0
  223. package/types/src/interop/yarn/yarn.types.d.ts +3 -0
  224. package/types/src/io/copy-file.d.ts +4 -0
  225. package/types/src/io/delete-file.d.ts +1 -0
  226. package/types/src/io/directory-exists.d.ts +1 -0
  227. package/types/src/io/file-exists.d.ts +1 -0
  228. package/types/src/io/find-directories.d.ts +2 -0
  229. package/types/src/io/find-file.d.ts +9 -0
  230. package/types/src/io/index.d.ts +2 -0
  231. package/types/src/io/io.d.ts +11 -0
  232. package/types/src/io/read-file.d.ts +4 -0
  233. package/types/src/io/remove-dir.d.ts +5 -0
  234. package/types/src/io/types/directory.type.d.ts +4 -0
  235. package/types/src/io/types/file.d.ts +20 -0
  236. package/types/src/io/types/index.d.ts +2 -0
  237. package/types/src/io/url-to-path.d.ts +2 -0
  238. package/types/src/io/watch.d.ts +16 -0
  239. package/types/src/io/write-file.d.ts +5 -0
  240. package/types/src/objects/deep-merge.d.ts +41 -0
  241. package/types/src/objects/index.d.ts +1 -0
  242. package/types/src/reflection/index.d.ts +3 -0
  243. package/types/src/reflection/types/index.d.ts +1 -0
  244. package/types/src/reflection/types/reflection.types.d.ts +21 -0
  245. package/types/src/reflection/utilities.d.ts +27 -0
  246. package/types/src/semver/index.d.ts +1 -0
  247. package/types/src/semver/semver.d.ts +18 -0
  248. package/types/src/system/camel-case.d.ts +1 -0
  249. package/types/src/system/debounce.d.ts +1 -0
  250. package/types/src/system/decorator.d.ts +15 -0
  251. package/types/src/system/environment.d.ts +6 -0
  252. package/types/src/system/function.types.d.ts +55 -0
  253. package/types/src/system/index.d.ts +7 -0
  254. package/types/src/system/retry.decorator.d.ts +6 -0
  255. package/types/src/system/sleep.d.ts +1 -0
  256. package/types/src/system/type.utils.d.ts +1 -0
  257. package/types/src/testing/flush-promises.d.ts +1 -0
  258. package/types/src/testing/glob-with-memfs.d.ts +3 -0
  259. package/types/src/testing/index.d.ts +5 -0
  260. package/types/src/testing/memfs.d.ts +5 -0
  261. package/types/src/testing/mock-logger.d.ts +13 -0
  262. package/types/src/testing/spy-on-constructor.d.ts +21 -0
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Pipeline", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Pipeline;
9
+ }
10
+ });
11
+ const _scribe = require("@decohere/scribe");
12
+ class Pipeline {
13
+ stack;
14
+ logger = _scribe.scribe.logger(Pipeline.name);
15
+ currentStep;
16
+ constructor(...steps){
17
+ this.stack = steps;
18
+ }
19
+ [Symbol.dispose]() {
20
+ for (const [, step] of this.stack){
21
+ if (Symbol.dispose in step) {
22
+ step[Symbol.dispose]();
23
+ }
24
+ }
25
+ }
26
+ async start(context) {
27
+ const runStep = async (index)=>{
28
+ const [key, middleware, when] = this.stack[index] ?? [];
29
+ if (middleware == null) {
30
+ return;
31
+ }
32
+ if (when != null && !when(context)) {
33
+ this.logger.info(`Skipping step ${key}`);
34
+ return await runStep(index + 1);
35
+ }
36
+ this.currentStep = key;
37
+ this.logger.info(`Running step ${key}`);
38
+ await middleware.run(context, async ()=>{
39
+ await runStep(index + 1);
40
+ });
41
+ };
42
+ try {
43
+ await runStep(0);
44
+ } catch (error) {
45
+ const step = this.currentStep ?? "unknown";
46
+ if (error instanceof Error) {
47
+ throw new Error(`Pipeline step '${step}' failed: ${error.message}`, {
48
+ cause: error
49
+ });
50
+ }
51
+ throw new Error(`Pipeline step '${step}' failed with non-Error value`, {
52
+ cause: error
53
+ });
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Step", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Step;
9
+ }
10
+ });
11
+ class Step {
12
+ type;
13
+ when;
14
+ constructor(type, when){
15
+ this.type = type;
16
+ this.when = when;
17
+ }
18
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Docker", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Docker;
9
+ }
10
+ });
11
+ const _interoperror = require("../errors/interop.error.js");
12
+ const _shell = require("../shell/shell.js");
13
+ class Docker extends _shell.Shell {
14
+ name = "docker";
15
+ program = "docker";
16
+ async build(contextDir, options = {}) {
17
+ if (contextDir == null || contextDir.trim() === "") {
18
+ throw new _interoperror.InteropError("Docker build context is required");
19
+ }
20
+ const args = [
21
+ "build"
22
+ ];
23
+ if (options.dockerfile) {
24
+ args.push("-f", options.dockerfile);
25
+ }
26
+ for (const tag of options.tags ?? []){
27
+ args.push("-t", tag);
28
+ }
29
+ for (const [key, value] of Object.entries(options.buildArgs ?? {})){
30
+ args.push("--build-arg", `${key}=${value}`);
31
+ }
32
+ for (const [id, env] of Object.entries(options.secrets ?? {})){
33
+ args.push("--secret", `id=${id},env=${env}`);
34
+ }
35
+ if (options.noCache) {
36
+ args.push("--no-cache");
37
+ }
38
+ if (options.pull) {
39
+ args.push("--pull");
40
+ }
41
+ args.push(contextDir);
42
+ return await this.run({
43
+ cwd: options.cwd
44
+ }, ...args);
45
+ }
46
+ async push(tag, options = {}) {
47
+ if (tag == null || tag.trim() === "") {
48
+ throw new _interoperror.InteropError("Docker tag is required");
49
+ }
50
+ return await this.run({
51
+ cwd: options.cwd
52
+ }, "push", tag);
53
+ }
54
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "InteropError", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return InteropError;
9
+ }
10
+ });
11
+ class InteropError extends Error {
12
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Git", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Git;
9
+ }
10
+ });
11
+ const _interoperror = require("../errors/interop.error.js");
12
+ const _shell = require("../shell/shell.js");
13
+ const Commands = {
14
+ stage: "stage",
15
+ tag: "tag",
16
+ add: "add",
17
+ commit: "commit",
18
+ push: "push",
19
+ listFiles: "ls-files"
20
+ };
21
+ const defaultOptions = {
22
+ cwd: "./"
23
+ };
24
+ class Git extends _shell.Shell {
25
+ program = "git";
26
+ async getModifiedFiles(options = defaultOptions) {
27
+ const args = [
28
+ Commands.listFiles,
29
+ "--modified"
30
+ ];
31
+ const { cwd } = options;
32
+ const result = await this.run({
33
+ cwd
34
+ }, ...args);
35
+ return result.data;
36
+ }
37
+ async getBranchName(options = defaultOptions) {
38
+ const { cwd } = options;
39
+ const args = [
40
+ "rev-parse",
41
+ "--symbolic-full-name",
42
+ "--abbrev-ref",
43
+ "HEAD"
44
+ ];
45
+ const result = await this.run({
46
+ cwd
47
+ }, ...args);
48
+ return result.data[0];
49
+ }
50
+ async tag(tag, options = defaultOptions) {
51
+ const args = [
52
+ Commands.tag,
53
+ tag
54
+ ];
55
+ const { cwd } = options;
56
+ const result = await this.run({
57
+ cwd
58
+ }, ...args);
59
+ return result;
60
+ }
61
+ async pushTag(tag, options = defaultOptions) {
62
+ const { cwd, remote = "origin" } = options;
63
+ const result = await this.run({
64
+ cwd
65
+ }, Commands.push, remote, tag);
66
+ return result;
67
+ }
68
+ async commit(message, options) {
69
+ const optionsAndDefaults = {
70
+ ...defaultOptions,
71
+ ...options
72
+ };
73
+ const { cwd, files = [], all } = optionsAndDefaults;
74
+ const args = [
75
+ Commands.commit
76
+ ];
77
+ if (files.length > 0 && all) {
78
+ throw new _interoperror.InteropError("Cannot commit all and files at the same time");
79
+ }
80
+ if (files.length > 0) {
81
+ await this.stage({
82
+ files
83
+ });
84
+ }
85
+ if (options.all) {
86
+ args.push("-a");
87
+ }
88
+ args.push("-m", message);
89
+ const result = await this.run({
90
+ cwd
91
+ }, ...args);
92
+ return result;
93
+ }
94
+ async push(branch, options) {
95
+ const optionsAndDefaults = {
96
+ ...defaultOptions,
97
+ ...options
98
+ };
99
+ const { cwd, setUpstream } = optionsAndDefaults;
100
+ const args = [
101
+ Commands.push
102
+ ];
103
+ args.push("--set-upstream", setUpstream ?? "origin");
104
+ args.push(branch);
105
+ const result = await this.run({
106
+ cwd
107
+ }, ...args);
108
+ return result;
109
+ }
110
+ async pull(branch, options = defaultOptions) {
111
+ const { cwd } = options;
112
+ return this.run({
113
+ cwd
114
+ }, "pull", "--rebase", "origin", branch);
115
+ }
116
+ async stage(options) {
117
+ const optionsAndDefaults = {
118
+ ...defaultOptions,
119
+ ...options
120
+ };
121
+ const { cwd, files = [], all } = optionsAndDefaults;
122
+ if (all) {
123
+ await this.run({
124
+ cwd
125
+ }, Commands.stage, "-a");
126
+ return;
127
+ }
128
+ for (const file of files){
129
+ await this.run({
130
+ cwd
131
+ }, Commands.stage, file);
132
+ }
133
+ }
134
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -0,0 +1,97 @@
1
+ // << Git >>
2
+ // << Docker >>
3
+ "use strict";
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ function _export(target, all) {
8
+ for(var name in all)Object.defineProperty(target, name, {
9
+ enumerable: true,
10
+ get: Object.getOwnPropertyDescriptor(all, name).get
11
+ });
12
+ }
13
+ _export(exports, {
14
+ get git () {
15
+ return _gittypes;
16
+ },
17
+ get npm () {
18
+ return _npmtypes;
19
+ },
20
+ get pnpm () {
21
+ return _pnpmtypes;
22
+ },
23
+ get shell () {
24
+ return _shelltypes;
25
+ },
26
+ get yarn () {
27
+ return _yarntypes;
28
+ }
29
+ });
30
+ _export_star(require("./docker/docker.js"), exports);
31
+ _export_star(require("./git/git.js"), exports);
32
+ const _gittypes = /*#__PURE__*/ _interop_require_wildcard(require("./git/git.types.js"));
33
+ _export_star(require("./node/node.js"), exports);
34
+ _export_star(require("./npm/npm.js"), exports);
35
+ const _npmtypes = /*#__PURE__*/ _interop_require_wildcard(require("./npm/npm.types.js"));
36
+ _export_star(require("./pnpm/pnpm.js"), exports);
37
+ const _pnpmtypes = /*#__PURE__*/ _interop_require_wildcard(require("./pnpm/pnpm.types.js"));
38
+ _export_star(require("./shell/shell.js"), exports);
39
+ const _shelltypes = /*#__PURE__*/ _interop_require_wildcard(require("./shell/shell.types.js"));
40
+ _export_star(require("./types/detect-package-manager.js"), exports);
41
+ _export_star(require("./types/package-manager.js"), exports);
42
+ _export_star(require("./yarn/yarn.js"), exports);
43
+ const _yarntypes = /*#__PURE__*/ _interop_require_wildcard(require("./yarn/yarn.types.js"));
44
+ function _export_star(from, to) {
45
+ Object.keys(from).forEach(function(k) {
46
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
47
+ Object.defineProperty(to, k, {
48
+ enumerable: true,
49
+ get: function() {
50
+ return from[k];
51
+ }
52
+ });
53
+ }
54
+ });
55
+ return from;
56
+ }
57
+ function _getRequireWildcardCache(nodeInterop) {
58
+ if (typeof WeakMap !== "function") return null;
59
+ var cacheBabelInterop = new WeakMap();
60
+ var cacheNodeInterop = new WeakMap();
61
+ return (_getRequireWildcardCache = function(nodeInterop) {
62
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
63
+ })(nodeInterop);
64
+ }
65
+ function _interop_require_wildcard(obj, nodeInterop) {
66
+ if (!nodeInterop && obj && obj.__esModule) {
67
+ return obj;
68
+ }
69
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
70
+ return {
71
+ default: obj
72
+ };
73
+ }
74
+ var cache = _getRequireWildcardCache(nodeInterop);
75
+ if (cache && cache.has(obj)) {
76
+ return cache.get(obj);
77
+ }
78
+ var newObj = {
79
+ __proto__: null
80
+ };
81
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
82
+ for(var key in obj){
83
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
84
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
85
+ if (desc && (desc.get || desc.set)) {
86
+ Object.defineProperty(newObj, key, desc);
87
+ } else {
88
+ newObj[key] = obj[key];
89
+ }
90
+ }
91
+ }
92
+ newObj.default = obj;
93
+ if (cache) {
94
+ cache.set(obj, newObj);
95
+ }
96
+ return newObj;
97
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./node.js"), exports);
6
+ function _export_star(from, to) {
7
+ Object.keys(from).forEach(function(k) {
8
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
+ Object.defineProperty(to, k, {
10
+ enumerable: true,
11
+ get: function() {
12
+ return from[k];
13
+ }
14
+ });
15
+ }
16
+ });
17
+ return from;
18
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Node", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Node;
9
+ }
10
+ });
11
+ const _nodechild_process = require("node:child_process");
12
+ const _shell = require("../shell/shell.js");
13
+ class Node extends _shell.Shell {
14
+ program = "node";
15
+ async runScript(script, ...args) {
16
+ const spawnOpt = {
17
+ cwd: ".",
18
+ stdio: "inherit",
19
+ env: {
20
+ ...process.env
21
+ }
22
+ };
23
+ return new Promise((resolve, reject)=>{
24
+ const proc = (0, _nodechild_process.spawn)("node", [
25
+ script,
26
+ ...args
27
+ ], spawnOpt);
28
+ proc.on("exit", (code)=>{
29
+ if (code !== 0) {
30
+ reject();
31
+ }
32
+ resolve(null);
33
+ });
34
+ proc.on("close", (code)=>{
35
+ resolve(null);
36
+ if (code === 0) {
37
+ resolve({
38
+ message: `${script} completed`
39
+ });
40
+ }
41
+ reject(`Running '${script}' failed with code ${code}`);
42
+ });
43
+ });
44
+ }
45
+ }
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Npm", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Npm;
9
+ }
10
+ });
11
+ const _interoperror = require("../errors/interop.error.js");
12
+ const _shell = require("../shell/shell.js");
13
+ function _getRequireWildcardCache(nodeInterop) {
14
+ if (typeof WeakMap !== "function") return null;
15
+ var cacheBabelInterop = new WeakMap();
16
+ var cacheNodeInterop = new WeakMap();
17
+ return (_getRequireWildcardCache = function(nodeInterop) {
18
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
19
+ })(nodeInterop);
20
+ }
21
+ function _interop_require_wildcard(obj, nodeInterop) {
22
+ if (!nodeInterop && obj && obj.__esModule) {
23
+ return obj;
24
+ }
25
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
26
+ return {
27
+ default: obj
28
+ };
29
+ }
30
+ var cache = _getRequireWildcardCache(nodeInterop);
31
+ if (cache && cache.has(obj)) {
32
+ return cache.get(obj);
33
+ }
34
+ var newObj = {
35
+ __proto__: null
36
+ };
37
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
38
+ for(var key in obj){
39
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
40
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
41
+ if (desc && (desc.get || desc.set)) {
42
+ Object.defineProperty(newObj, key, desc);
43
+ } else {
44
+ newObj[key] = obj[key];
45
+ }
46
+ }
47
+ }
48
+ newObj.default = obj;
49
+ if (cache) {
50
+ cache.set(obj, newObj);
51
+ }
52
+ return newObj;
53
+ }
54
+ const Commands = {
55
+ publish: "publish",
56
+ version: "version",
57
+ link: "link",
58
+ install: "install"
59
+ };
60
+ class Npm extends _shell.Shell {
61
+ name = "npm";
62
+ program = "npm";
63
+ async publish(directory, options = {
64
+ channel: "beta"
65
+ }) {
66
+ const { cwd, dryRun, skipIfPublished, channel, authToken, otp, provenance } = options;
67
+ if (directory == null) {
68
+ throw new _interoperror.InteropError("Directory is required");
69
+ }
70
+ if (skipIfPublished && !dryRun) {
71
+ const alreadyPublished = await this.isPublished(directory, {
72
+ cwd
73
+ });
74
+ if (alreadyPublished) {
75
+ return {
76
+ message: `Skipping publish — version already exists on registry`,
77
+ data: []
78
+ };
79
+ }
80
+ }
81
+ const args = [
82
+ Commands.publish,
83
+ directory
84
+ ];
85
+ let tmpUserConfigPath;
86
+ args.push("--tag", channel ?? "beta");
87
+ if (provenance) {
88
+ args.push("--provenance");
89
+ }
90
+ // Explicit --token (local bootstrap). OIDC publish must not inherit cwd .npmrc / NODE_AUTH_TOKEN.
91
+ if (authToken?.trim()) {
92
+ tmpUserConfigPath = await this.createTempUserConfig(authToken.trim());
93
+ args.push("--userconfig", tmpUserConfigPath);
94
+ }
95
+ if (dryRun) {
96
+ args.push("--dry-run");
97
+ }
98
+ const env = {
99
+ ...process.env
100
+ };
101
+ if (!authToken?.trim()) {
102
+ delete env.NODE_AUTH_TOKEN;
103
+ delete env.NPM_TOKEN;
104
+ env.NPM_CONFIG_USERCONFIG = "/dev/null";
105
+ }
106
+ if (otp) {
107
+ env.NPM_CONFIG_OTP = otp;
108
+ }
109
+ try {
110
+ return await this.run({
111
+ cwd,
112
+ env
113
+ }, ...args);
114
+ } catch (error) {
115
+ if (skipIfPublished && !dryRun && isAlreadyPublishedError(error)) {
116
+ return {
117
+ message: `Skipping publish — version already exists on registry`,
118
+ data: []
119
+ };
120
+ }
121
+ throw error;
122
+ } finally{
123
+ if (tmpUserConfigPath) {
124
+ await this.removeTempUserConfig(tmpUserConfigPath);
125
+ }
126
+ }
127
+ }
128
+ /**
129
+ * @description Runs in the directory of the package
130
+ * @param options
131
+ * @returns
132
+ */ async version(versionType, options) {
133
+ const { cwd, noTag, preid } = options;
134
+ const args = [
135
+ Commands.version,
136
+ versionType
137
+ ];
138
+ if (noTag) {
139
+ args.push("--no-git-tag-version");
140
+ }
141
+ if (preid) {
142
+ args.push("--preid", preid);
143
+ }
144
+ return this.run({
145
+ cwd
146
+ }, ...args);
147
+ }
148
+ async link(directory, options = {
149
+ cwd: "./"
150
+ }) {
151
+ const { cwd } = options;
152
+ const args = [
153
+ Commands.link,
154
+ directory
155
+ ];
156
+ return this.run({
157
+ cwd
158
+ }, ...args);
159
+ }
160
+ async install(options = {
161
+ cwd: "./"
162
+ }) {
163
+ const { cwd } = options;
164
+ return this.run({
165
+ cwd
166
+ }, Commands.install);
167
+ }
168
+ /**
169
+ * Install only `dependencies` as real folders: `--omit=dev` skips devDependencies and
170
+ * `--no-bin-links` skips the `.bin` symlinks, so the result holds no symlinks at all.
171
+ */ async installProduction(options = {
172
+ cwd: "./"
173
+ }) {
174
+ const { cwd } = options;
175
+ return this.run({
176
+ cwd
177
+ }, Commands.install, "--omit=dev", "--no-bin-links", "--no-audit", "--no-fund", "--loglevel=error");
178
+ }
179
+ async syncLockFile(options = {
180
+ cwd: "./"
181
+ }) {
182
+ const { cwd } = options;
183
+ return this.run({
184
+ cwd
185
+ }, Commands.install, "--package-lock-only", "--ignore-scripts");
186
+ }
187
+ /**
188
+ * True when package@version exists on the registry.
189
+ * Uses ambient npm config (cwd `.npmrc`); do not pass tokens on argv.
190
+ */ async isPublished(directory, options) {
191
+ const { readFileSync } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:fs")));
192
+ const { join } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:path")));
193
+ try {
194
+ const pkgJson = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
195
+ const spec = `${pkgJson.name}@${pkgJson.version}`;
196
+ await this.run(options, "view", spec, "version");
197
+ return true;
198
+ } catch {
199
+ return false;
200
+ }
201
+ }
202
+ async createTempUserConfig(authToken) {
203
+ const { mkdtemp, writeFile } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:fs/promises")));
204
+ const { tmpdir } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:os")));
205
+ const { join } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:path")));
206
+ const tempDir = await mkdtemp(join(tmpdir(), "decohere-npmrc-"));
207
+ const npmrcPath = join(tempDir, ".npmrc");
208
+ const npmrc = [
209
+ "registry=https://registry.npmjs.org/",
210
+ "always-auth=true",
211
+ `//registry.npmjs.org/:_authToken=${authToken}`
212
+ ].join("\n");
213
+ await writeFile(npmrcPath, `${npmrc}\n`, {
214
+ mode: 0o600
215
+ });
216
+ return npmrcPath;
217
+ }
218
+ async removeTempUserConfig(npmrcPath) {
219
+ const { rm } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:fs/promises")));
220
+ const { dirname } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("node:path")));
221
+ const dir = dirname(npmrcPath);
222
+ await rm(dir, {
223
+ recursive: true,
224
+ force: true
225
+ });
226
+ }
227
+ }
228
+ function isAlreadyPublishedError(error) {
229
+ const message = error instanceof Error ? error.message : String(error);
230
+ return /cannot publish over the previously published versions/i.test(message);
231
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "VersionTypes", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return VersionTypes;
9
+ }
10
+ });
11
+ const VersionTypes = {
12
+ major: "major",
13
+ minor: "minor",
14
+ patch: "patch",
15
+ prerelease: "prerelease"
16
+ };