@blazetrails/thor 0.0.0-stage → 0.1.0-alpha0.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.
Files changed (97) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +9 -0
  3. package/dist/actions/create-file.d.ts +23 -0
  4. package/dist/actions/create-file.js +69 -0
  5. package/dist/actions/create-file.js.map +1 -0
  6. package/dist/actions/create-link.d.ts +10 -0
  7. package/dist/actions/create-link.js +34 -0
  8. package/dist/actions/create-link.js.map +1 -0
  9. package/dist/actions/directory.d.ts +31 -0
  10. package/dist/actions/directory.js +76 -0
  11. package/dist/actions/directory.js.map +1 -0
  12. package/dist/actions/empty-directory.d.ts +36 -0
  13. package/dist/actions/empty-directory.js +95 -0
  14. package/dist/actions/empty-directory.js.map +1 -0
  15. package/dist/actions/file-manipulation.d.ts +64 -0
  16. package/dist/actions/file-manipulation.js +190 -0
  17. package/dist/actions/file-manipulation.js.map +1 -0
  18. package/dist/actions/inject-into-file.d.ts +31 -0
  19. package/dist/actions/inject-into-file.js +111 -0
  20. package/dist/actions/inject-into-file.js.map +1 -0
  21. package/dist/actions.d.ts +120 -0
  22. package/dist/actions.js +287 -0
  23. package/dist/actions.js.map +1 -0
  24. package/dist/base.d.ts +223 -0
  25. package/dist/base.js +455 -0
  26. package/dist/base.js.map +1 -0
  27. package/dist/command.d.ts +69 -0
  28. package/dist/command.js +169 -0
  29. package/dist/command.js.map +1 -0
  30. package/dist/constants.generated.d.ts +2 -0
  31. package/dist/constants.generated.js +74 -0
  32. package/dist/constants.generated.js.map +1 -0
  33. package/dist/core-ext/hash-with-indifferent-access.d.ts +32 -0
  34. package/dist/core-ext/hash-with-indifferent-access.js +99 -0
  35. package/dist/core-ext/hash-with-indifferent-access.js.map +1 -0
  36. package/dist/error.d.ts +62 -0
  37. package/dist/error.js +105 -0
  38. package/dist/error.js.map +1 -0
  39. package/dist/group.d.ts +66 -0
  40. package/dist/group.js +313 -0
  41. package/dist/group.js.map +1 -0
  42. package/dist/invocation.d.ts +63 -0
  43. package/dist/invocation.js +104 -0
  44. package/dist/invocation.js.map +1 -0
  45. package/dist/line-editor/basic.d.ts +12 -0
  46. package/dist/line-editor/basic.js +30 -0
  47. package/dist/line-editor/basic.js.map +1 -0
  48. package/dist/line-editor.d.ts +4 -0
  49. package/dist/line-editor.js +9 -0
  50. package/dist/line-editor.js.map +1 -0
  51. package/dist/nested-context.d.ts +12 -0
  52. package/dist/nested-context.js +28 -0
  53. package/dist/nested-context.js.map +1 -0
  54. package/dist/parser/argument.d.ts +34 -0
  55. package/dist/parser/argument.js +103 -0
  56. package/dist/parser/argument.js.map +1 -0
  57. package/dist/parser/arguments.d.ts +42 -0
  58. package/dist/parser/arguments.js +164 -0
  59. package/dist/parser/arguments.js.map +1 -0
  60. package/dist/parser/option.d.ts +45 -0
  61. package/dist/parser/option.js +164 -0
  62. package/dist/parser/option.js.map +1 -0
  63. package/dist/parser/options.d.ts +69 -0
  64. package/dist/parser/options.js +332 -0
  65. package/dist/parser/options.js.map +1 -0
  66. package/dist/shell/basic.d.ts +64 -0
  67. package/dist/shell/basic.js +288 -0
  68. package/dist/shell/basic.js.map +1 -0
  69. package/dist/shell/color.d.ts +29 -0
  70. package/dist/shell/color.js +52 -0
  71. package/dist/shell/color.js.map +1 -0
  72. package/dist/shell/column-printer.d.ts +16 -0
  73. package/dist/shell/column-printer.js +28 -0
  74. package/dist/shell/column-printer.js.map +1 -0
  75. package/dist/shell/table-printer.d.ts +31 -0
  76. package/dist/shell/table-printer.js +120 -0
  77. package/dist/shell/table-printer.js.map +1 -0
  78. package/dist/shell/terminal.d.ts +4 -0
  79. package/dist/shell/terminal.js +35 -0
  80. package/dist/shell/terminal.js.map +1 -0
  81. package/dist/shell/wrapped-printer.d.ts +5 -0
  82. package/dist/shell/wrapped-printer.js +37 -0
  83. package/dist/shell/wrapped-printer.js.map +1 -0
  84. package/dist/shell.d.ts +51 -0
  85. package/dist/shell.js +129 -0
  86. package/dist/shell.js.map +1 -0
  87. package/dist/thor.d.ts +174 -0
  88. package/dist/thor.js +640 -0
  89. package/dist/thor.js.map +1 -0
  90. package/dist/util.d.ts +16 -0
  91. package/dist/util.js +87 -0
  92. package/dist/util.js.map +1 -0
  93. package/dist/version.d.ts +2 -0
  94. package/dist/version.js +2 -0
  95. package/dist/version.js.map +1 -0
  96. package/package.json +55 -3
  97. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dean Marano and Trails contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ @blazetrails/thor
2
+ =================
3
+
4
+ This package is a TypeScript port of the thor gem
5
+ (https://github.com/rails/thor), licensed under the MIT License.
6
+
7
+ Original copyrights:
8
+
9
+ thor — Copyright (c) 2008 Yehuda Katz, Eric Hodel, et al., MIT License.
@@ -0,0 +1,23 @@
1
+ import type { ActionsHost } from "../actions.js";
2
+ import { EmptyDirectory, type EmptyDirectoryBase } from "./empty-directory.js";
3
+ type Block = () => unknown;
4
+ type Data = string | Uint8Array | (() => unknown);
5
+ export declare function createFile(this: ActionsHost, destination: string, ...args: unknown[]): unknown;
6
+ export declare const addFile: typeof createFile;
7
+ export declare class CreateFile extends EmptyDirectory {
8
+ data: Data;
9
+ /** @internal */
10
+ private _render?;
11
+ constructor(base: EmptyDirectoryBase, destination: string | null | undefined, data: Data, config?: Record<string, unknown>);
12
+ isIdentical(): Promise<boolean>;
13
+ render(): Promise<string | Uint8Array>;
14
+ invokeBang(): Promise<string>;
15
+ /** @internal */
16
+ protected onConflictBehavior(block: Block): Promise<void>;
17
+ /** @internal */
18
+ protected forceOrSkipOrConflict(force: unknown, skip: unknown, block: Block): Promise<void>;
19
+ /** @internal */
20
+ protected isForceOnCollision(): unknown;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=create-file.d.ts.map
@@ -0,0 +1,69 @@
1
+ import { bytes, File, FileUtils, forceEncoding, getFs, Hash, merge, rbEqual, rbObjIsKindOf, rtest, toS, } from "@blazetrails/ruby-compat";
2
+ import { EmptyDirectory } from "./empty-directory.js";
3
+ export function createFile(destination, ...args) {
4
+ const block = (typeof args[args.length - 1] === "function" ? args.pop() : undefined);
5
+ const config = (rbObjIsKindOf(args.at(-1) ?? null, Hash) ? args.pop() : {});
6
+ const data = args[0];
7
+ return this.action(new CreateFile(this, destination, block || (data instanceof Uint8Array ? data : toS(data)), config));
8
+ }
9
+ export const addFile = createFile;
10
+ export class CreateFile extends EmptyDirectory {
11
+ data;
12
+ /** @internal */
13
+ _render;
14
+ constructor(base, destination, data, config = {}) {
15
+ super(base, destination, config);
16
+ this.data = data;
17
+ }
18
+ async isIdentical() {
19
+ let render;
20
+ return ((await this.isExists()) &&
21
+ rbEqual(await getFs().readFile(this.destination), (render = forceEncoding(await this.render(), "ASCII-8BIT")) instanceof Uint8Array
22
+ ? render
23
+ : Uint8Array.from(bytes(render))));
24
+ }
25
+ async render() {
26
+ return (this._render ??= (typeof this.data === "function" ? await this.data() : this.data));
27
+ }
28
+ async invokeBang() {
29
+ await this.invokeWithConflictCheck(async () => {
30
+ await FileUtils.mkdirPAsync(File.dirname(this.destination));
31
+ const render = await this.render();
32
+ await File.writeAsync(this.destination, render instanceof Uint8Array ? render : Uint8Array.from(bytes(render)), {
33
+ perm: this.config["perm"],
34
+ });
35
+ });
36
+ return this.givenDestination;
37
+ }
38
+ /** @internal */
39
+ async onConflictBehavior(block) {
40
+ if (await this.isIdentical()) {
41
+ this.sayStatus("identical", ":blue");
42
+ }
43
+ else {
44
+ // eslint-disable-next-line blazetrails/ruby-compat-native-required -- base.options is a HashWithIndifferentAccess, which merge dispatches on
45
+ const options = merge(this.base.options, this.config);
46
+ await this.forceOrSkipOrConflict(options["force"], options["skip"], block);
47
+ }
48
+ }
49
+ /** @internal */
50
+ async forceOrSkipOrConflict(force, skip, block) {
51
+ if (rtest(force)) {
52
+ this.sayStatus("force", ":yellow");
53
+ if (!rtest(this.isPretend()))
54
+ await block();
55
+ }
56
+ else if (rtest(skip)) {
57
+ this.sayStatus("skip", ":yellow");
58
+ }
59
+ else {
60
+ this.sayStatus("conflict", ":red");
61
+ await this.forceOrSkipOrConflict(await this.isForceOnCollision(), true, block);
62
+ }
63
+ }
64
+ /** @internal */
65
+ isForceOnCollision() {
66
+ return this.base.shell.fileCollision(this.destination, () => this.render());
67
+ }
68
+ }
69
+ //# sourceMappingURL=create-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-file.js","sourceRoot":"","sources":["../../lib/actions/create-file.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,aAAa,EACb,KAAK,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EACP,aAAa,EACb,KAAK,EACL,GAAG,GACJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,cAAc,EAA2B,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OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACtD,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IAED,gBAAgB;IACN,KAAK,CAAC,qBAAqB,CACnC,KAAc,EACd,IAAa,EACb,KAAY;QAEZ,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACnC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBAAE,MAAM,KAAK,EAAE,CAAC;QAC9C,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACnC,MAAM,IAAI,CAAC,qBAAqB,CAAC,MAAM,IAAI,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAED,gBAAgB;IACN,kBAAkB;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9E,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import type { ActionsHost } from "../actions.js";
2
+ import { CreateFile } from "./create-file.js";
3
+ export declare function createLink(this: ActionsHost, destination: string, ...args: unknown[]): unknown;
4
+ export declare const addLink: typeof createLink;
5
+ export declare class CreateLink extends CreateFile {
6
+ isIdentical(): Promise<boolean>;
7
+ invokeBang(): Promise<string>;
8
+ isExists(): Promise<boolean>;
9
+ }
10
+ //# sourceMappingURL=create-link.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { File, FileUtils, Hash, rbObjIsKindOf, rtest } from "@blazetrails/ruby-compat";
2
+ import { CreateFile } from "./create-file.js";
3
+ export function createLink(destination, ...args) {
4
+ const config = (rbObjIsKindOf(args.at(-1) ?? null, Hash) ? args.pop() : {});
5
+ const source = args[0];
6
+ return this.action(new CreateLink(this, destination, source, config));
7
+ }
8
+ export const addLink = createLink;
9
+ export class CreateLink extends CreateFile {
10
+ async isIdentical() {
11
+ const source = File.expandPath((await this.render()), File.dirname(this.destination));
12
+ return (await this.isExists()) && (await File.isIdenticalAsync(source, this.destination));
13
+ }
14
+ async invokeBang() {
15
+ await this.invokeWithConflictCheck(async () => {
16
+ await FileUtils.mkdirPAsync(File.dirname(this.destination));
17
+ if (this.config["symbolic"] == null)
18
+ this.config["symbolic"] = true;
19
+ if (await this.isExists())
20
+ await File.deleteAsync(this.destination);
21
+ if (rtest(this.config["symbolic"])) {
22
+ await File.symlinkAsync((await this.render()), this.destination);
23
+ }
24
+ else {
25
+ await File.linkAsync((await this.render()), this.destination);
26
+ }
27
+ });
28
+ return this.givenDestination;
29
+ }
30
+ async isExists() {
31
+ return (await super.isExists()) || (await File.isSymlinkAsync(this.destination));
32
+ }
33
+ }
34
+ //# sourceMappingURL=create-link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-link.js","sourceRoot":"","sources":["../../lib/actions/create-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,UAAU,UAAU,CAAoB,WAAmB,EAAE,GAAG,IAAe;IACnF,MAAM,MAAM,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CA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nC,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YAC7E,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAEQ,KAAK,CAAC,QAAQ;QACrB,OAAO,CAAC,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACnF,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ import type { ActionsHost } from "../actions.js";
2
+ import { EmptyDirectory } from "./empty-directory.js";
3
+ type Block = (content: string) => unknown;
4
+ type DirectoryBase = ActionsHost & {
5
+ emptyDirectory(destination: string, config?: Record<string, unknown>): unknown;
6
+ template(source: string, ...args: unknown[]): Promise<unknown>;
7
+ copyFile(source: string, ...args: unknown[]): Promise<unknown>;
8
+ };
9
+ export declare function directory(this: ActionsHost, source: string, ...args: unknown[]): Promise<unknown>;
10
+ export declare class Directory extends EmptyDirectory {
11
+ source: string;
12
+ /** @internal */
13
+ private _block;
14
+ protected constructor(base: DirectoryBase, source: string, destination?: string | null, config?: Record<string, unknown>, block?: Block);
15
+ static new<T extends Directory>(this: {
16
+ prototype: T;
17
+ }, base: DirectoryBase, source: string, destination?: string | null, config?: Record<string, unknown>, block?: Block): Promise<T>;
18
+ invokeBang(): Promise<unknown>;
19
+ revokeBang(): Promise<unknown>;
20
+ /**
21
+ * @internal
22
+ * @inventedArm if — PERMANENT
23
+ */
24
+ protected executeBang(): Promise<unknown>;
25
+ /** @internal */
26
+ protected fileLevelLookup(previousLookup: string): string;
27
+ /** @internal */
28
+ protected files(lookup: string): Promise<string[]>;
29
+ }
30
+ export {};
31
+ //# sourceMappingURL=directory.d.ts.map
@@ -0,0 +1,76 @@
1
+ import { Dir, File, Hash, rbClassNewInstance, rbObjIsKindOf, rtest, sort, toS, } from "@blazetrails/ruby-compat";
2
+ import { TEMPLATE_EXTNAME } from "../base.js";
3
+ import { escapeGlobs } from "../util.js";
4
+ import { EmptyDirectory } from "./empty-directory.js";
5
+ export async function directory(source, ...args) {
6
+ const block = (typeof args[args.length - 1] === "function" ? args.pop() : undefined);
7
+ const config = (rbObjIsKindOf(args.at(-1) ?? null, Hash) ? args.pop() : {});
8
+ const destination = args[0] ?? source;
9
+ return this.action(await Directory.new(this, source, destination ?? source, config, block));
10
+ }
11
+ export class Directory extends EmptyDirectory {
12
+ source;
13
+ /** @internal */
14
+ _block;
15
+ constructor(base, source, destination = null, config = {}, block) {
16
+ super(base, destination, { recursive: true, ...config });
17
+ this._block = block;
18
+ }
19
+ static async new(base, source, destination = null, config = {}, block) {
20
+ const obj = rbClassNewInstance(this, base, source, destination, config, block);
21
+ obj.source = File.expandPath((await Dir.globAsync(escapeGlobs(await base.findInSourcePaths(toS(source)))))[0] ?? null);
22
+ return obj;
23
+ }
24
+ async invokeBang() {
25
+ await this.base.emptyDirectory(this.givenDestination, this.config);
26
+ return this.executeBang();
27
+ }
28
+ async revokeBang() {
29
+ return this.executeBang();
30
+ }
31
+ /**
32
+ * @internal
33
+ * @inventedArm if — PERMANENT
34
+ */
35
+ async executeBang() {
36
+ const source = this.source;
37
+ let lookup = escapeGlobs(source);
38
+ lookup = rtest(this.config["recursive"]) ? File.join(lookup, "**") : lookup;
39
+ lookup = this.fileLevelLookup(lookup);
40
+ const files = sort(await this.files(lookup));
41
+ for (const fileSource of files) {
42
+ if (await File.isDirectoryAsync(fileSource))
43
+ continue;
44
+ const excludePattern = this.config["excludePattern"];
45
+ if (rtest(excludePattern) && fileSource.match(excludePattern))
46
+ continue;
47
+ const compiled = /^(.*\.tt)\.(js|js\.map|d\.ts)$/.exec(fileSource);
48
+ if (compiled && files.includes(compiled[1]))
49
+ continue;
50
+ let fileDestination = File.join(this.givenDestination, fileSource.replaceAll(source, "."));
51
+ fileDestination = fileDestination.replaceAll("/./", "/");
52
+ if (/\.empty_directory$/.test(fileSource)) {
53
+ const dirname = File.dirname(fileDestination).replace(/\/\.$/, "");
54
+ if (dirname === this.givenDestination)
55
+ continue;
56
+ await this.base.emptyDirectory(dirname, this.config);
57
+ }
58
+ else if (RegExp(`${TEMPLATE_EXTNAME}$`).test(fileSource)) {
59
+ await this.base.template(fileSource, fileDestination.slice(0, -3), this.config, ...(this._block ? [this._block] : []));
60
+ }
61
+ else {
62
+ await this.base.copyFile(fileSource, fileDestination, this.config, ...(this._block ? [this._block] : []));
63
+ }
64
+ }
65
+ return files;
66
+ }
67
+ /** @internal */
68
+ fileLevelLookup(previousLookup) {
69
+ return File.join(previousLookup, "*");
70
+ }
71
+ /** @internal */
72
+ files(lookup) {
73
+ return Dir.globAsync(lookup, File.FNM_DOTMATCH);
74
+ }
75
+ }
76
+ //# sourceMappingURL=directory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory.js","sourceRoot":"","sources":["../../lib/actions/directory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACb,KAAK,EACL,IAAI,EACJ,GAAG,GACJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAStD,MAAM,CAAC,KAAK,UAAU,SAAS,CAE7B,MAAc,EACd,GAAG,IAAe;IAElB,MAAM,KAAK,GAAG,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,UAAU,CAAC,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,CAAC;IACf,CAAC;IAED,gBAAgB;IACN,eAAe,CAAC,cAAsB;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,gBAAgB;IACN,KAAK,CAAC,MAAc;QAC5B,OAAO,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import type { ActionsHost } from "../actions.js";
2
+ export type EmptyDirectoryBase = Pick<ActionsHost, "options" | "shell" | "destinationRoot" | "relativeToOriginalDestinationRoot">;
3
+ type Block = () => unknown;
4
+ export declare function emptyDirectory(this: ActionsHost, destination: string, config?: Record<string, unknown>): unknown;
5
+ export declare class EmptyDirectory {
6
+ base: EmptyDirectoryBase;
7
+ givenDestination: string;
8
+ relativeDestination: string;
9
+ config: Record<string, unknown>;
10
+ /** @internal */
11
+ private _destination;
12
+ constructor(base: EmptyDirectoryBase, destination: string | null | undefined, config?: Record<string, unknown>);
13
+ get destination(): string;
14
+ isExists(): Promise<boolean>;
15
+ invokeBang(): Promise<unknown>;
16
+ revokeBang(): Promise<unknown>;
17
+ /** @internal */
18
+ protected isPretend(): unknown;
19
+ /** @internal */
20
+ protected set destination(destination: string | null | undefined);
21
+ /**
22
+ * @internal
23
+ * @inventedArm replace — PERMANENT
24
+ */
25
+ protected convertEncodedInstructions(filename: string): string;
26
+ /** @internal */
27
+ protected invokeWithConflictCheck(block: Block): Promise<unknown>;
28
+ /** @internal */
29
+ protected onFileClashBehavior(): void;
30
+ /** @internal */
31
+ protected onConflictBehavior(..._rest: unknown[]): void | Promise<void>;
32
+ /** @internal */
33
+ protected sayStatus(status: string, color: unknown): void;
34
+ }
35
+ export {};
36
+ //# sourceMappingURL=empty-directory.d.ts.map
@@ -0,0 +1,95 @@
1
+ import { Errno, FileUtils, File, rbFSend, rbObjRespondTo, rtest, strip, toS, } from "@blazetrails/ruby-compat";
2
+ export function emptyDirectory(destination, config = {}) {
3
+ return this.action(new EmptyDirectory(this, destination, config));
4
+ }
5
+ export class EmptyDirectory {
6
+ base;
7
+ givenDestination;
8
+ relativeDestination;
9
+ config;
10
+ /** @internal */
11
+ _destination;
12
+ constructor(base, destination, config = {}) {
13
+ this.base = base;
14
+ this.config = { verbose: true, ...config };
15
+ this.destination = destination;
16
+ }
17
+ get destination() {
18
+ return this._destination;
19
+ }
20
+ isExists() {
21
+ return File.isExistAsync(this.destination);
22
+ }
23
+ invokeBang() {
24
+ return this.invokeWithConflictCheck(async () => {
25
+ await FileUtils.mkdirPAsync(this.destination);
26
+ });
27
+ }
28
+ async revokeBang() {
29
+ this.sayStatus("remove", ":red");
30
+ if (!rtest(this.isPretend()) && (await this.isExists())) {
31
+ await FileUtils.rmRfAsync(this.destination);
32
+ }
33
+ return this.givenDestination;
34
+ }
35
+ /** @internal */
36
+ isPretend() {
37
+ return this.base.options["pretend"];
38
+ }
39
+ /** @internal */
40
+ set destination(destination) {
41
+ if (!rtest(destination))
42
+ return;
43
+ this.givenDestination = this.convertEncodedInstructions(toS(destination));
44
+ this._destination = File.expandPath(this.givenDestination, this.base.destinationRoot);
45
+ this.relativeDestination = this.base.relativeToOriginalDestinationRoot(this._destination);
46
+ }
47
+ /**
48
+ * @internal
49
+ * @inventedArm replace — PERMANENT
50
+ */
51
+ convertEncodedInstructions(filename) {
52
+ return filename.replace(/%(.*?)%/g, (initialString, $1) => {
53
+ const name = strip($1);
54
+ const method = rbObjRespondTo(this.base, name)
55
+ ? name
56
+ : name.replace(/(?<=[a-zA-Z\d])_([a-zA-Z\d])/g, (_, c) => c.toUpperCase());
57
+ return rbObjRespondTo(this.base, method) ? toS(rbFSend(this.base, method)) : initialString;
58
+ });
59
+ }
60
+ /** @internal */
61
+ async invokeWithConflictCheck(block) {
62
+ try {
63
+ if (await this.isExists()) {
64
+ await this.onConflictBehavior(block);
65
+ }
66
+ else {
67
+ if (!rtest(this.isPretend()))
68
+ await block();
69
+ this.sayStatus("create", ":green");
70
+ }
71
+ return this.destination;
72
+ }
73
+ catch (error) {
74
+ if (error instanceof Errno.EISDIR || error instanceof Errno.EEXIST) {
75
+ return this.onFileClashBehavior();
76
+ }
77
+ throw error;
78
+ }
79
+ }
80
+ /** @internal */
81
+ onFileClashBehavior() {
82
+ this.sayStatus("file_clash", ":red");
83
+ }
84
+ /** @internal */
85
+ onConflictBehavior(..._rest) {
86
+ this.sayStatus("exist", ":blue");
87
+ }
88
+ /** @internal */
89
+ sayStatus(status, color) {
90
+ if (rtest(this.config["verbose"])) {
91
+ this.base.shell.sayStatus(status, this.relativeDestination, color);
92
+ }
93
+ }
94
+ }
95
+ //# sourceMappingURL=empty-directory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-directory.js","sourceRoot":"","sources":["../../lib/actions/empty-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,IAAI,EACJ,OAAO,EACP,cAAc,EACd,KAAK,EACL,KAAK,EACL,GAAG,GACJ,MAAM,0BAA0B,CAAC;AAUlC,MAAM,UAAU,cAAc,CAE5B,WAAmB,EACnB,MAAM,GAA4B,EAAE;IAEpC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,OAAO,cAAc;IACzB,IAAI,CAAqB;IACzB,gBAAgB,CAAU;IAC1B,mBAAmB,CAAU;IAC7B,MAAM,CAA0B;IAChC,gBAAgB;IACR,YAAY,CAAU;IAE9B,YACE,IAAwB,EACxB,WAAsC,EACtC,MAAM,GAA4B,EAAE;QAEpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,IAA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gB;IACN,mBAAmB;QAC3B,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,gBAAgB;IACN,kBAAkB,CAAC,GAAG,KAAgB;QAC9C,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,gBAAgB;IACN,SAAS,CAAC,MAAc,EAAE,KAAc;QAChD,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,64 @@
1
+ import { StringIO, TSE, type TSECompiler } from "@blazetrails/ruby-compat";
2
+ import type { ActionsHost } from "../actions.js";
3
+ import type { createFile } from "./create-file.js";
4
+ import type { createLink } from "./create-link.js";
5
+ import type { insertIntoFile } from "./inject-into-file.js";
6
+ type FileHost = ActionsHost & {
7
+ createFile: typeof createFile;
8
+ createLink: typeof createLink;
9
+ chmod: typeof chmod;
10
+ };
11
+ type BufferHost = {
12
+ outputBuffer: StringIO | null;
13
+ _outputBuffer?: StringIO | null;
14
+ };
15
+ export declare function copyFile(this: FileHost, source: string, ...args: unknown[]): Promise<void>;
16
+ export declare function linkFile(this: FileHost, source: string, ...args: unknown[]): Promise<unknown>;
17
+ /**
18
+ * @inventedArm if — PERMANENT
19
+ * @inventedArm throw — PERMANENT
20
+ */
21
+ export declare function get(this: FileHost, source: string, ...args: unknown[]): Promise<unknown>;
22
+ /** @missingRailsArgs new — PERMANENT */
23
+ export declare function template(this: FileHost, source: string, ...args: unknown[]): Promise<unknown>;
24
+ type GsubHost = ActionsHost & {
25
+ gsubFile: typeof gsubFile;
26
+ };
27
+ type InsertHost = ActionsHost & {
28
+ insertIntoFile: typeof insertIntoFile;
29
+ };
30
+ export declare function chmod(this: ActionsHost, path: string | {
31
+ toPath(): string;
32
+ }, mode: number, config?: Record<string, unknown>): Promise<void>;
33
+ export declare function prependToFile(this: InsertHost, path: string, ...args: unknown[]): unknown;
34
+ export declare const prependFile: typeof prependToFile;
35
+ export declare function appendToFile(this: InsertHost, path: string, ...args: unknown[]): unknown;
36
+ export declare const appendFile: typeof appendToFile;
37
+ export declare function injectIntoClass(this: InsertHost, path: string, klass: unknown, ...args: unknown[]): unknown;
38
+ export declare function injectIntoModule(this: InsertHost, path: string, moduleName: unknown, ...args: unknown[]): unknown;
39
+ export declare function gsubFileBang(this: ActionsHost, path: string | {
40
+ toPath(): string;
41
+ }, flag: RegExp | string, ...args: unknown[]): Promise<void>;
42
+ export declare function gsubFile(this: ActionsHost, path: string | {
43
+ toPath(): string;
44
+ }, flag: RegExp | string, ...args: unknown[]): Promise<void>;
45
+ export declare function uncommentLines(this: GsubHost, path: string | {
46
+ toPath(): string;
47
+ }, flag: RegExp | string, ...args: unknown[]): Promise<void>;
48
+ export declare function commentLines(this: GsubHost, path: string | {
49
+ toPath(): string;
50
+ }, flag: RegExp | string, ...args: unknown[]): Promise<void>;
51
+ export declare function removeFile(this: ActionsHost, path: string | {
52
+ toPath(): string;
53
+ }, config?: Record<string, unknown>): Promise<void>;
54
+ export declare const removeDir: typeof removeFile;
55
+ export declare function outputBuffer(this: BufferHost): StringIO | null;
56
+ export declare function setOutputBuffer(this: BufferHost, outputBuffer: StringIO | null): void;
57
+ export declare function concat(this: BufferHost, string: string): void;
58
+ export declare function capture(this: BufferHost, ...args: unknown[]): string;
59
+ export declare function withOutputBuffer(this: BufferHost, buf: StringIO | undefined, block: () => unknown): string;
60
+ export declare class CapturableERB extends TSE {
61
+ setEoutvar(compiler: TSECompiler, eoutvar?: string): void;
62
+ }
63
+ export {};
64
+ //# sourceMappingURL=file-manipulation.d.ts.map