@intecoag/inteco-cli 1.11.8 → 1.12.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/adbBridge.d.ts +2 -0
- package/dist/modules/adbBridge.d.ts.map +1 -0
- package/dist/modules/adbBridge.js +40 -0
- package/dist/modules/adbBridge.js.map +1 -0
- package/dist/modules/adbBridge.test.d.ts +2 -0
- package/dist/modules/adbBridge.test.d.ts.map +1 -0
- package/dist/modules/adbBridge.test.js +39 -0
- package/dist/modules/adbBridge.test.js.map +1 -0
- package/dist/modules/adbIntentSender.d.ts +2 -0
- package/dist/modules/adbIntentSender.d.ts.map +1 -0
- package/dist/modules/adbIntentSender.js +67 -0
- package/dist/modules/adbIntentSender.js.map +1 -0
- package/dist/modules/adbIntentSender.test.d.ts +2 -0
- package/dist/modules/adbIntentSender.test.d.ts.map +1 -0
- package/dist/modules/adbIntentSender.test.js +48 -0
- package/dist/modules/adbIntentSender.test.js.map +1 -0
- package/dist/modules/azureSync.d.ts +16 -0
- package/dist/modules/azureSync.d.ts.map +1 -0
- package/{src → dist}/modules/azureSync.js +55 -136
- package/dist/modules/azureSync.js.map +1 -0
- package/dist/modules/azureSync.test.d.ts +2 -0
- package/dist/modules/azureSync.test.d.ts.map +1 -0
- package/dist/modules/azureSync.test.js +69 -0
- package/dist/modules/azureSync.test.js.map +1 -0
- package/dist/modules/bundleProduct.d.ts +2 -0
- package/dist/modules/bundleProduct.d.ts.map +1 -0
- package/{src → dist}/modules/bundleProduct.js +41 -80
- package/dist/modules/bundleProduct.js.map +1 -0
- package/dist/modules/bundleProduct.test.d.ts +2 -0
- package/dist/modules/bundleProduct.test.d.ts.map +1 -0
- package/dist/modules/bundleProduct.test.js +75 -0
- package/dist/modules/bundleProduct.test.js.map +1 -0
- package/dist/modules/changelog.d.ts +3 -0
- package/dist/modules/changelog.d.ts.map +1 -0
- package/dist/modules/changelog.js +45 -0
- package/dist/modules/changelog.js.map +1 -0
- package/dist/modules/changelog.test.d.ts +2 -0
- package/dist/modules/changelog.test.d.ts.map +1 -0
- package/dist/modules/changelog.test.js +33 -0
- package/dist/modules/changelog.test.js.map +1 -0
- package/dist/modules/configMutation.d.ts +5 -0
- package/dist/modules/configMutation.d.ts.map +1 -0
- package/{src → dist}/modules/configMutation.js +57 -104
- package/dist/modules/configMutation.js.map +1 -0
- package/dist/modules/configMutation.test.d.ts +2 -0
- package/dist/modules/configMutation.test.d.ts.map +1 -0
- package/dist/modules/configMutation.test.js +28 -0
- package/dist/modules/configMutation.test.js.map +1 -0
- package/dist/modules/csvMerger.d.ts +2 -0
- package/dist/modules/csvMerger.d.ts.map +1 -0
- package/dist/modules/csvMerger.js +104 -0
- package/dist/modules/csvMerger.js.map +1 -0
- package/dist/modules/csvMerger.test.d.ts +2 -0
- package/dist/modules/csvMerger.test.d.ts.map +1 -0
- package/dist/modules/csvMerger.test.js +76 -0
- package/dist/modules/csvMerger.test.js.map +1 -0
- package/dist/modules/deleteDB.d.ts +2 -0
- package/dist/modules/deleteDB.d.ts.map +1 -0
- package/dist/modules/deleteDB.js +75 -0
- package/dist/modules/deleteDB.js.map +1 -0
- package/dist/modules/deleteDB.test.d.ts +2 -0
- package/dist/modules/deleteDB.test.d.ts.map +1 -0
- package/dist/modules/deleteDB.test.js +78 -0
- package/dist/modules/deleteDB.test.js.map +1 -0
- package/dist/modules/dumpDB.d.ts +3 -0
- package/dist/modules/dumpDB.d.ts.map +1 -0
- package/{src → dist}/modules/dumpDB.js +64 -89
- package/dist/modules/dumpDB.js.map +1 -0
- package/dist/modules/dumpDB.test.d.ts +2 -0
- package/dist/modules/dumpDB.test.d.ts.map +1 -0
- package/dist/modules/dumpDB.test.js +104 -0
- package/dist/modules/dumpDB.test.js.map +1 -0
- package/dist/modules/dumpTableToCSV.d.ts +4 -0
- package/dist/modules/dumpTableToCSV.d.ts.map +1 -0
- package/dist/modules/dumpTableToCSV.js +135 -0
- package/dist/modules/dumpTableToCSV.js.map +1 -0
- package/dist/modules/dumpTableToCSV.test.d.ts +2 -0
- package/dist/modules/dumpTableToCSV.test.d.ts.map +1 -0
- package/dist/modules/dumpTableToCSV.test.js +15 -0
- package/dist/modules/dumpTableToCSV.test.js.map +1 -0
- package/dist/modules/extdSearch.d.ts +2 -0
- package/dist/modules/extdSearch.d.ts.map +1 -0
- package/{src → dist}/modules/extdSearch.js +60 -60
- package/dist/modules/extdSearch.js.map +1 -0
- package/dist/modules/extdSearch.test.d.ts +2 -0
- package/dist/modules/extdSearch.test.d.ts.map +1 -0
- package/dist/modules/extdSearch.test.js +114 -0
- package/dist/modules/extdSearch.test.js.map +1 -0
- package/dist/modules/githubDeploymentKey.d.ts +3 -0
- package/dist/modules/githubDeploymentKey.d.ts.map +1 -0
- package/dist/modules/githubDeploymentKey.js +241 -0
- package/dist/modules/githubDeploymentKey.js.map +1 -0
- package/dist/modules/githubDeploymentKey.test.d.ts +2 -0
- package/dist/modules/githubDeploymentKey.test.d.ts.map +1 -0
- package/dist/modules/githubDeploymentKey.test.js +50 -0
- package/dist/modules/githubDeploymentKey.test.js.map +1 -0
- package/dist/modules/githubDeploymentKeysList.d.ts +6 -0
- package/dist/modules/githubDeploymentKeysList.d.ts.map +1 -0
- package/dist/modules/githubDeploymentKeysList.js +185 -0
- package/dist/modules/githubDeploymentKeysList.js.map +1 -0
- package/dist/modules/githubDeploymentKeysList.test.d.ts +2 -0
- package/dist/modules/githubDeploymentKeysList.test.d.ts.map +1 -0
- package/dist/modules/githubDeploymentKeysList.test.js +70 -0
- package/dist/modules/githubDeploymentKeysList.test.js.map +1 -0
- package/dist/modules/githubSecurityAdvisories.d.ts +3 -0
- package/dist/modules/githubSecurityAdvisories.d.ts.map +1 -0
- package/dist/modules/githubSecurityAdvisories.js +145 -0
- package/dist/modules/githubSecurityAdvisories.js.map +1 -0
- package/dist/modules/githubSecurityAdvisories.test.d.ts +2 -0
- package/dist/modules/githubSecurityAdvisories.test.d.ts.map +1 -0
- package/dist/modules/githubSecurityAdvisories.test.js +67 -0
- package/dist/modules/githubSecurityAdvisories.test.js.map +1 -0
- package/dist/modules/graphqlSchemaExport.d.ts +2 -0
- package/dist/modules/graphqlSchemaExport.d.ts.map +1 -0
- package/dist/modules/graphqlSchemaExport.js +59 -0
- package/dist/modules/graphqlSchemaExport.js.map +1 -0
- package/dist/modules/graphqlSchemaExport.test.d.ts +2 -0
- package/dist/modules/graphqlSchemaExport.test.d.ts.map +1 -0
- package/dist/modules/graphqlSchemaExport.test.js +61 -0
- package/dist/modules/graphqlSchemaExport.test.js.map +1 -0
- package/dist/modules/importDB.d.ts +2 -0
- package/dist/modules/importDB.d.ts.map +1 -0
- package/{src → dist}/modules/importDB.js +48 -66
- package/dist/modules/importDB.js.map +1 -0
- package/dist/modules/importDB.test.d.ts +2 -0
- package/dist/modules/importDB.test.d.ts.map +1 -0
- package/dist/modules/importDB.test.js +65 -0
- package/dist/modules/importDB.test.js.map +1 -0
- package/dist/modules/rewriteConfig.d.ts +3 -0
- package/dist/modules/rewriteConfig.d.ts.map +1 -0
- package/dist/modules/rewriteConfig.js +75 -0
- package/dist/modules/rewriteConfig.js.map +1 -0
- package/dist/modules/rewriteConfig.test.d.ts +2 -0
- package/dist/modules/rewriteConfig.test.d.ts.map +1 -0
- package/dist/modules/rewriteConfig.test.js +62 -0
- package/dist/modules/rewriteConfig.test.js.map +1 -0
- package/dist/modules/setCLIConfig.d.ts +2 -0
- package/dist/modules/setCLIConfig.d.ts.map +1 -0
- package/dist/modules/setCLIConfig.js +29 -0
- package/dist/modules/setCLIConfig.js.map +1 -0
- package/dist/modules/setCLIConfig.test.d.ts +2 -0
- package/dist/modules/setCLIConfig.test.d.ts.map +1 -0
- package/dist/modules/setCLIConfig.test.js +40 -0
- package/dist/modules/setCLIConfig.test.js.map +1 -0
- package/dist/modules/syncConfig.d.ts +4 -0
- package/dist/modules/syncConfig.d.ts.map +1 -0
- package/{src → dist}/modules/syncConfig.js +76 -129
- package/dist/modules/syncConfig.js.map +1 -0
- package/dist/modules/syncConfig.test.d.ts +2 -0
- package/dist/modules/syncConfig.test.d.ts.map +1 -0
- package/dist/modules/syncConfig.test.js +71 -0
- package/dist/modules/syncConfig.test.js.map +1 -0
- package/dist/modules/t003Rewrite.d.ts +2 -0
- package/dist/modules/t003Rewrite.d.ts.map +1 -0
- package/dist/modules/t003Rewrite.js +53 -0
- package/dist/modules/t003Rewrite.js.map +1 -0
- package/dist/modules/t003Rewrite.test.d.ts +2 -0
- package/dist/modules/t003Rewrite.test.d.ts.map +1 -0
- package/dist/modules/t003Rewrite.test.js +43 -0
- package/dist/modules/t003Rewrite.test.js.map +1 -0
- package/dist/modules/t009Search.d.ts +2 -0
- package/dist/modules/t009Search.d.ts.map +1 -0
- package/dist/modules/t009Search.js +30 -0
- package/dist/modules/t009Search.js.map +1 -0
- package/dist/modules/t009Search.test.d.ts +2 -0
- package/dist/modules/t009Search.test.d.ts.map +1 -0
- package/dist/modules/t009Search.test.js +83 -0
- package/dist/modules/t009Search.test.js.map +1 -0
- package/{src → dist}/ressources/cmds.json +3 -0
- package/dist/utils/azure/azure.d.ts +24 -0
- package/dist/utils/azure/azure.d.ts.map +1 -0
- package/{src → dist}/utils/azure/azure.js +14 -21
- package/dist/utils/azure/azure.js.map +1 -0
- package/dist/utils/azure/azure.test.d.ts +2 -0
- package/dist/utils/azure/azure.test.d.ts.map +1 -0
- package/dist/utils/azure/azure.test.js +98 -0
- package/dist/utils/azure/azure.test.js.map +1 -0
- package/dist/utils/config/config.d.ts +27 -0
- package/dist/utils/config/config.d.ts.map +1 -0
- package/dist/utils/config/config.js +74 -0
- package/dist/utils/config/config.js.map +1 -0
- package/dist/utils/config/config.test.d.ts +2 -0
- package/dist/utils/config/config.test.d.ts.map +1 -0
- package/dist/utils/config/config.test.js +64 -0
- package/dist/utils/config/config.test.js.map +1 -0
- package/dist/utils/db/DB.d.ts +14 -0
- package/dist/utils/db/DB.d.ts.map +1 -0
- package/dist/utils/db/DB.js +61 -0
- package/dist/utils/db/DB.js.map +1 -0
- package/dist/utils/db/DB.test.d.ts +2 -0
- package/dist/utils/db/DB.test.d.ts.map +1 -0
- package/dist/utils/db/DB.test.js +73 -0
- package/dist/utils/db/DB.test.js.map +1 -0
- package/dist/utils/fs/FS.d.ts +15 -0
- package/dist/utils/fs/FS.d.ts.map +1 -0
- package/{src → dist}/utils/fs/FS.js +31 -45
- package/dist/utils/fs/FS.js.map +1 -0
- package/dist/utils/fs/FS.test.d.ts +2 -0
- package/dist/utils/fs/FS.test.d.ts.map +1 -0
- package/dist/utils/fs/FS.test.js +124 -0
- package/dist/utils/fs/FS.test.js.map +1 -0
- package/dist/utils/github/github.d.ts +29 -0
- package/dist/utils/github/github.d.ts.map +1 -0
- package/dist/utils/github/github.js +96 -0
- package/dist/utils/github/github.js.map +1 -0
- package/dist/utils/github/github.test.d.ts +2 -0
- package/dist/utils/github/github.test.d.ts.map +1 -0
- package/dist/utils/github/github.test.js +83 -0
- package/dist/utils/github/github.test.js.map +1 -0
- package/dist/utils/shell/DatabaseShell.d.ts +77 -0
- package/dist/utils/shell/DatabaseShell.d.ts.map +1 -0
- package/{src → dist}/utils/shell/DatabaseShell.js +73 -87
- package/dist/utils/shell/DatabaseShell.js.map +1 -0
- package/dist/utils/shell/DatabaseShell.test.d.ts +2 -0
- package/dist/utils/shell/DatabaseShell.test.d.ts.map +1 -0
- package/dist/utils/shell/DatabaseShell.test.js +78 -0
- package/dist/utils/shell/DatabaseShell.test.js.map +1 -0
- package/dist/utils/shell/DatabaseShellBuilder.d.ts +67 -0
- package/dist/utils/shell/DatabaseShellBuilder.d.ts.map +1 -0
- package/{src → dist}/utils/shell/DatabaseShellBuilder.js +50 -59
- package/dist/utils/shell/DatabaseShellBuilder.js.map +1 -0
- package/dist/utils/shell/DatabaseShellBuilder.test.d.ts +2 -0
- package/dist/utils/shell/DatabaseShellBuilder.test.d.ts.map +1 -0
- package/dist/utils/shell/DatabaseShellBuilder.test.js +55 -0
- package/dist/utils/shell/DatabaseShellBuilder.test.js.map +1 -0
- package/dist/utils/shell/Shell.d.ts +30 -0
- package/dist/utils/shell/Shell.d.ts.map +1 -0
- package/{src → dist}/utils/shell/Shell.js +14 -19
- package/dist/utils/shell/Shell.js.map +1 -0
- package/dist/utils/shell/Shell.test.d.ts +2 -0
- package/dist/utils/shell/Shell.test.d.ts.map +1 -0
- package/dist/utils/shell/Shell.test.js +65 -0
- package/dist/utils/shell/Shell.test.js.map +1 -0
- package/dist/utils/shell/ShellBuilder.d.ts +60 -0
- package/dist/utils/shell/ShellBuilder.d.ts.map +1 -0
- package/{src → dist}/utils/shell/ShellBuilder.js +23 -44
- package/dist/utils/shell/ShellBuilder.js.map +1 -0
- package/dist/utils/shell/ShellBuilder.test.d.ts +2 -0
- package/dist/utils/shell/ShellBuilder.test.d.ts.map +1 -0
- package/dist/utils/shell/ShellBuilder.test.js +39 -0
- package/dist/utils/shell/ShellBuilder.test.js.map +1 -0
- package/package.json +39 -11
- package/.github/dependabot.yml +0 -28
- package/.github/workflows/publish.yml +0 -31
- package/.husky/commit-msg +0 -1
- package/.vscode/settings.json +0 -6
- package/commitlint.config.mjs +0 -4
- package/src/index.js +0 -130
- package/src/modules/adbBridge.js +0 -52
- package/src/modules/adbIntentSender.js +0 -82
- package/src/modules/changelog.js +0 -60
- package/src/modules/csvMerger.js +0 -118
- package/src/modules/deleteDB.js +0 -84
- package/src/modules/dumpTableToCSV.js +0 -154
- package/src/modules/githubDeploymentKey.js +0 -265
- package/src/modules/githubDeploymentKeysList.js +0 -199
- package/src/modules/githubSecurityAdvisories.js +0 -162
- package/src/modules/graphqlSchemaExport.js +0 -61
- package/src/modules/rewriteConfig.js +0 -93
- package/src/modules/setCLIConfig.js +0 -33
- package/src/modules/t003Rewrite.js +0 -64
- package/src/modules/t009Search.js +0 -34
- package/src/utils/config/config.js +0 -70
- package/src/utils/db/DB.js +0 -54
- package/src/utils/github/github.js +0 -102
- /package/{src → dist}/ressources/wegas_p.ico +0 -0
- /package/{src → dist}/utils/config/default.json +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { Shell } from "./Shell.js";
|
|
3
|
+
const mocks = vi.hoisted(() => ({
|
|
4
|
+
prompts: vi.fn()
|
|
5
|
+
}));
|
|
6
|
+
vi.mock("prompts", () => ({
|
|
7
|
+
default: mocks.prompts
|
|
8
|
+
}));
|
|
9
|
+
describe("Shell", () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
vi.clearAllMocks();
|
|
12
|
+
});
|
|
13
|
+
it("handleCommand returns true when first handler matches", async () => {
|
|
14
|
+
const shell = new Shell();
|
|
15
|
+
const first = vi.fn().mockResolvedValue(true);
|
|
16
|
+
const second = vi.fn().mockResolvedValue(true);
|
|
17
|
+
shell.commandHandlers = [first, second];
|
|
18
|
+
const handled = await shell.handleCommand(":x");
|
|
19
|
+
expect(handled).toBe(true);
|
|
20
|
+
expect(first).toHaveBeenCalledTimes(1);
|
|
21
|
+
expect(second).not.toHaveBeenCalled();
|
|
22
|
+
});
|
|
23
|
+
it("handleCommand returns false when no handler matches", async () => {
|
|
24
|
+
const shell = new Shell();
|
|
25
|
+
shell.commandHandlers = [vi.fn().mockResolvedValue(false)];
|
|
26
|
+
const handled = await shell.handleCommand(":x");
|
|
27
|
+
expect(handled).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
it("run dispatches input and exits when handler requests it", async () => {
|
|
30
|
+
const shell = new Shell();
|
|
31
|
+
shell.name = "TestShell";
|
|
32
|
+
shell.prompt = "prompt";
|
|
33
|
+
shell.autocomplete = [":q"];
|
|
34
|
+
shell.commandHandlers = [
|
|
35
|
+
async (s, input) => {
|
|
36
|
+
if (input === ":q") {
|
|
37
|
+
s.exit();
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
mocks.prompts.mockResolvedValue({ input: ":q" });
|
|
44
|
+
await shell.run();
|
|
45
|
+
expect(mocks.prompts).toHaveBeenCalledTimes(1);
|
|
46
|
+
expect(shell.exitRequested).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
it("run trims input before handling", async () => {
|
|
49
|
+
const shell = new Shell();
|
|
50
|
+
shell.name = "TrimShell";
|
|
51
|
+
shell.prompt = "prompt";
|
|
52
|
+
const seen = [];
|
|
53
|
+
shell.commandHandlers = [
|
|
54
|
+
(s, input) => {
|
|
55
|
+
seen.push(input);
|
|
56
|
+
s.exit();
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
mocks.prompts.mockResolvedValue({ input: " :hello " });
|
|
61
|
+
await shell.run();
|
|
62
|
+
expect(seen).toEqual([":hello"]);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=Shell.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Shell.test.js","sourceRoot":"","sources":["../../../src/utils/shell/Shell.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5B,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE;CACnB,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;IACtB,OAAO,EAAE,KAAK,CAAC,OAAO;CACzB,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACnB,UAAU,CAAC,GAA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,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Shell, type ShellCommand, type ShellCommandHandler } from "./Shell.js";
|
|
2
|
+
export declare class ShellBuilder {
|
|
3
|
+
commands: ShellCommand[];
|
|
4
|
+
commandHandlers: ShellCommandHandler[];
|
|
5
|
+
name: string;
|
|
6
|
+
prompt: string;
|
|
7
|
+
useBuiltInHandler: boolean;
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Adds the built-in command handler
|
|
11
|
+
* @returns {ShellBuilder}
|
|
12
|
+
*/
|
|
13
|
+
withBuiltInHandler(): this;
|
|
14
|
+
/**
|
|
15
|
+
* Adds the built-in commands (:q and :?), requires a supported handler to work
|
|
16
|
+
* @returns {ShellBuilder}
|
|
17
|
+
*/
|
|
18
|
+
withBuiltInCommands(): this;
|
|
19
|
+
/**
|
|
20
|
+
* Add a command to be executed by the built in command handler
|
|
21
|
+
* @param {String} commandName The command name to be entered in the command line
|
|
22
|
+
* @param {String} helpText The text displayed in the help
|
|
23
|
+
* @param {(shell: Shell, input: String, ...args: String[]) => void} handler The handler to be executed with the executing shell passed as an arugment
|
|
24
|
+
* @returns {ShellBuilder}
|
|
25
|
+
*/
|
|
26
|
+
withCommand(commandName: string, helpText: string, handler: (shell: Shell, input: string, ...args: string[]) => Promise<unknown> | unknown): ShellBuilder;
|
|
27
|
+
/**
|
|
28
|
+
* Change the name of the shell
|
|
29
|
+
* @param {String} name The name of the shell used in some texts
|
|
30
|
+
* @returns {ShellBuilder}
|
|
31
|
+
*/
|
|
32
|
+
withName(name: string): ShellBuilder;
|
|
33
|
+
/**
|
|
34
|
+
* Change the prompt displayed when entering text
|
|
35
|
+
* @param {String} prompt The text to be displayed in the prompt
|
|
36
|
+
* @returns {ShellBuilder}
|
|
37
|
+
*/
|
|
38
|
+
withPrompt(prompt: string): ShellBuilder;
|
|
39
|
+
/**
|
|
40
|
+
* Add a command handler to be executed if the inputted command doesn't correspond to a built in handler
|
|
41
|
+
* @param {(shell: Shell, input: String) => boolean} handler The handler to be executed with the inputted text and shell passed as arguments.
|
|
42
|
+
* Return true to signal that the handler was successful and shouldn't continue with another handler.
|
|
43
|
+
*
|
|
44
|
+
* @returns {ShellBuilder}
|
|
45
|
+
*/
|
|
46
|
+
withCommandHandler(handler: ShellCommandHandler): ShellBuilder;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a usable shell with the built-in and custom functions.
|
|
49
|
+
* @returns {Shell}
|
|
50
|
+
*/
|
|
51
|
+
build(): Shell;
|
|
52
|
+
/**
|
|
53
|
+
* Splits a command into args with support for spaces and and escape sequences
|
|
54
|
+
* @private
|
|
55
|
+
* @param {String} input The unformatted command
|
|
56
|
+
* @returns {String[]}
|
|
57
|
+
*/
|
|
58
|
+
parseArgs(input: string): string[];
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=ShellBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShellBuilder.d.ts","sourceRoot":"","sources":["../../../src/utils/shell/ShellBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEhF,qBAAa,YAAY;IACrB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,eAAe,EAAE,mBAAmB,EAAE,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,OAAO,CAAC;;IAU3B;;;OAGG;IACH,kBAAkB;IAyBlB;;;OAGG;IACH,mBAAmB;IAenB;;;;;;OAMG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,YAAY;IASzJ;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAKpC;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAKxC;;;;;;OAMG;IACH,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY;IAK9D;;;OAGG;IACH,KAAK,IAAI,KAAK;IAWd;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CA8CrC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import { Shell } from "./
|
|
3
|
-
|
|
2
|
+
import { Shell } from "./Shell.js";
|
|
4
3
|
export class ShellBuilder {
|
|
5
|
-
|
|
4
|
+
commands;
|
|
5
|
+
commandHandlers;
|
|
6
|
+
name;
|
|
7
|
+
prompt;
|
|
8
|
+
useBuiltInHandler;
|
|
6
9
|
constructor() {
|
|
7
10
|
this.commands = [];
|
|
8
11
|
this.commandHandlers = [];
|
|
@@ -10,7 +13,6 @@ export class ShellBuilder {
|
|
|
10
13
|
this.prompt = "Interactive Shell (show help with :?)";
|
|
11
14
|
this.useBuiltInHandler = false;
|
|
12
15
|
}
|
|
13
|
-
|
|
14
16
|
/**
|
|
15
17
|
* Adds the built-in command handler
|
|
16
18
|
* @returns {ShellBuilder}
|
|
@@ -18,47 +20,38 @@ export class ShellBuilder {
|
|
|
18
20
|
withBuiltInHandler() {
|
|
19
21
|
this.withCommandHandler(async (shell, input) => {
|
|
20
22
|
const parts = this.parseArgs(input);
|
|
21
|
-
if(parts.length == 0)
|
|
22
|
-
|
|
23
|
+
if (parts.length == 0)
|
|
24
|
+
return false;
|
|
23
25
|
const commandName = parts[0];
|
|
24
26
|
const args = parts.slice(1);
|
|
25
|
-
|
|
26
|
-
for(let i = 0; i < shell.commands.length; i++) {
|
|
27
|
+
for (let i = 0; i < shell.commands.length; i++) {
|
|
27
28
|
const command = shell.commands[i];
|
|
28
|
-
|
|
29
|
-
if(command.name == commandName) {
|
|
29
|
+
if (command.name == commandName) {
|
|
30
30
|
await command.handler(shell, input, ...args);
|
|
31
31
|
return true;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
|
|
35
34
|
return false;
|
|
36
35
|
});
|
|
37
|
-
|
|
38
36
|
this.useBuiltInHandler = true;
|
|
39
|
-
|
|
40
37
|
return this;
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
/**
|
|
44
40
|
* Adds the built-in commands (:q and :?), requires a supported handler to work
|
|
45
41
|
* @returns {ShellBuilder}
|
|
46
42
|
*/
|
|
47
43
|
withBuiltInCommands() {
|
|
48
44
|
this.withCommand(":q", "Exit the shell", shell => {
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
shell.exit();
|
|
46
|
+
})
|
|
51
47
|
.withCommand(":?", "Shows this help", shell => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.log(`${chalk.yellow(command.name)} - ${command.helpText}`);
|
|
56
|
-
});
|
|
48
|
+
console.log("\n" + chalk.cyan("Available Commands:"));
|
|
49
|
+
shell.commands.forEach(command => {
|
|
50
|
+
console.log(`${chalk.yellow(command.name)} - ${command.helpText}`);
|
|
57
51
|
});
|
|
58
|
-
|
|
52
|
+
});
|
|
59
53
|
return this;
|
|
60
54
|
}
|
|
61
|
-
|
|
62
55
|
/**
|
|
63
56
|
* Add a command to be executed by the built in command handler
|
|
64
57
|
* @param {String} commandName The command name to be entered in the command line
|
|
@@ -74,7 +67,6 @@ export class ShellBuilder {
|
|
|
74
67
|
});
|
|
75
68
|
return this;
|
|
76
69
|
}
|
|
77
|
-
|
|
78
70
|
/**
|
|
79
71
|
* Change the name of the shell
|
|
80
72
|
* @param {String} name The name of the shell used in some texts
|
|
@@ -84,7 +76,6 @@ export class ShellBuilder {
|
|
|
84
76
|
this.name = name;
|
|
85
77
|
return this;
|
|
86
78
|
}
|
|
87
|
-
|
|
88
79
|
/**
|
|
89
80
|
* Change the prompt displayed when entering text
|
|
90
81
|
* @param {String} prompt The text to be displayed in the prompt
|
|
@@ -94,34 +85,30 @@ export class ShellBuilder {
|
|
|
94
85
|
this.prompt = prompt;
|
|
95
86
|
return this;
|
|
96
87
|
}
|
|
97
|
-
|
|
98
88
|
/**
|
|
99
89
|
* Add a command handler to be executed if the inputted command doesn't correspond to a built in handler
|
|
100
90
|
* @param {(shell: Shell, input: String) => boolean} handler The handler to be executed with the inputted text and shell passed as arguments.
|
|
101
91
|
* Return true to signal that the handler was successful and shouldn't continue with another handler.
|
|
102
|
-
*
|
|
92
|
+
*
|
|
103
93
|
* @returns {ShellBuilder}
|
|
104
94
|
*/
|
|
105
95
|
withCommandHandler(handler) {
|
|
106
96
|
this.commandHandlers.push(handler);
|
|
107
97
|
return this;
|
|
108
98
|
}
|
|
109
|
-
|
|
110
99
|
/**
|
|
111
100
|
* Creates a usable shell with the built-in and custom functions.
|
|
112
101
|
* @returns {Shell}
|
|
113
102
|
*/
|
|
114
103
|
build() {
|
|
115
|
-
|
|
104
|
+
const shell = new Shell();
|
|
116
105
|
shell.commands = this.commands;
|
|
117
106
|
shell.name = this.name;
|
|
118
107
|
shell.prompt = this.prompt;
|
|
119
108
|
shell.commandHandlers = this.commandHandlers;
|
|
120
|
-
shell.autocomplete = shell.commands.map(c => c.name);
|
|
121
|
-
|
|
109
|
+
shell.autocomplete = shell.commands.map((c) => c.name);
|
|
122
110
|
return shell;
|
|
123
111
|
}
|
|
124
|
-
|
|
125
112
|
/**
|
|
126
113
|
* Splits a command into args with support for spaces and and escape sequences
|
|
127
114
|
* @private
|
|
@@ -133,45 +120,37 @@ export class ShellBuilder {
|
|
|
133
120
|
let current = "";
|
|
134
121
|
let inQuotes = false;
|
|
135
122
|
let escaping = false;
|
|
136
|
-
|
|
137
123
|
for (let i = 0; i < input.length; i++) {
|
|
138
124
|
const char = input[i];
|
|
139
|
-
|
|
140
125
|
if (escaping) {
|
|
141
126
|
current += char;
|
|
142
127
|
escaping = false;
|
|
143
128
|
continue;
|
|
144
129
|
}
|
|
145
|
-
|
|
146
130
|
if (char === "\\") {
|
|
147
131
|
escaping = true;
|
|
148
132
|
continue;
|
|
149
133
|
}
|
|
150
|
-
|
|
151
134
|
if (char === '"') {
|
|
152
135
|
inQuotes = !inQuotes;
|
|
153
136
|
continue;
|
|
154
137
|
}
|
|
155
|
-
|
|
156
138
|
if (char === " " && !inQuotes) {
|
|
157
139
|
if (current.length > 0) {
|
|
158
|
-
|
|
159
|
-
|
|
140
|
+
result.push(current);
|
|
141
|
+
current = "";
|
|
160
142
|
}
|
|
161
143
|
continue;
|
|
162
144
|
}
|
|
163
|
-
|
|
164
145
|
current += char;
|
|
165
146
|
}
|
|
166
|
-
|
|
167
147
|
if (escaping) {
|
|
168
148
|
current += "\\";
|
|
169
149
|
}
|
|
170
|
-
|
|
171
150
|
if (current.length > 0) {
|
|
172
151
|
result.push(current);
|
|
173
152
|
}
|
|
174
|
-
|
|
175
153
|
return result;
|
|
176
154
|
}
|
|
177
|
-
}
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=ShellBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShellBuilder.js","sourceRoot":"","sources":["../../../src/utils/shell/ShellBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAA+C,MAAM,YAAY,CAAC;AAEhF,MAAM,OAAO,YAAY;IACrB,QAAQ,CAAiB;IACzB,eAAe,CAAwB;IACvC,IAAI,CAAS;IACb,MAAM,CAAS;IACf,iBAAiB,CAAU;IAE3B;QACI,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC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EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShellBuilder.test.d.ts","sourceRoot":"","sources":["../../../src/utils/shell/ShellBuilder.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { ShellBuilder } from "./ShellBuilder.js";
|
|
3
|
+
describe("ShellBuilder", () => {
|
|
4
|
+
it("parses quoted and escaped args", () => {
|
|
5
|
+
const builder = new ShellBuilder();
|
|
6
|
+
const args = builder.parseArgs(':cmd "hello world" test\\ value "x\\"y"');
|
|
7
|
+
expect(args).toEqual([":cmd", "hello world", "test value", 'x"y']);
|
|
8
|
+
});
|
|
9
|
+
it("builds shell with configured metadata and commands", () => {
|
|
10
|
+
const handler = vi.fn();
|
|
11
|
+
const shell = new ShellBuilder()
|
|
12
|
+
.withName("My Shell")
|
|
13
|
+
.withPrompt("prompt>")
|
|
14
|
+
.withCommand(":x", "Runs x", handler)
|
|
15
|
+
.build();
|
|
16
|
+
expect(shell.name).toBe("My Shell");
|
|
17
|
+
expect(shell.prompt).toBe("prompt>");
|
|
18
|
+
expect(shell.commands).toHaveLength(1);
|
|
19
|
+
expect(shell.commands[0]?.name).toBe(":x");
|
|
20
|
+
expect(shell.autocomplete).toEqual([":x"]);
|
|
21
|
+
});
|
|
22
|
+
it("executes built-in command handler for matching command", async () => {
|
|
23
|
+
const cmd = vi.fn();
|
|
24
|
+
const shell = new ShellBuilder()
|
|
25
|
+
.withBuiltInHandler()
|
|
26
|
+
.withCommand(":echo", "Echo", cmd)
|
|
27
|
+
.build();
|
|
28
|
+
const handled = await shell.handleCommand(':echo "hi there" a\\ b');
|
|
29
|
+
expect(handled).toBe(true);
|
|
30
|
+
expect(cmd).toHaveBeenCalledTimes(1);
|
|
31
|
+
expect(cmd.mock.calls[0]?.slice(2)).toEqual(["hi there", "a b"]);
|
|
32
|
+
});
|
|
33
|
+
it("returns false when no built-in command matches", async () => {
|
|
34
|
+
const shell = new ShellBuilder().withBuiltInHandler().build();
|
|
35
|
+
const handled = await shell.handleCommand(":missing");
|
|
36
|
+
expect(handled).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=ShellBuilder.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShellBuilder.test.js","sourceRoot":"","sources":["../../../src/utils/shell/ShellBuilder.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,MAAM,OAAO,GAAG,IAAI,YAAY,EAAE,CAAC;QAEnC,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC;QAE1E,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC1D,MAAM,OAAO,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,IAAI,YAAY,EAAE;aAC3B,QAAQ,CAAC,UAAU,CAAC;aACpB,UAAU,CAAC,SAAS,CAAC;aACrB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC;aACpC,KAAK,EAAE,CAAC;QAEb,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAA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AAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAEtD,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intecoag/inteco-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0-beta.2",
|
|
4
4
|
"description": "CLI-Tools for Inteco",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"clean": "node -e \"import('node:fs').then(fs=>fs.rmSync('dist',{recursive:true,force:true}))\"",
|
|
9
|
+
"build": "npm run clean && tsc && node scripts/copy-assets.mjs",
|
|
10
|
+
"typecheck": "tsc --noEmit",
|
|
11
|
+
"test:ci": "vitest run --coverage --reporter=default --reporter=json --outputFile=vitest-results.json",
|
|
12
|
+
"test": "vitest run --coverage",
|
|
13
|
+
"test:watch": "vitest --coverage",
|
|
14
|
+
"start": "node dist/index.js",
|
|
15
|
+
"dev": "tsx src/index.ts",
|
|
16
|
+
"prepare": "husky",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
10
18
|
},
|
|
11
19
|
"author": "ah1",
|
|
12
20
|
"license": "ISC",
|
|
13
21
|
"repository": "https://github.com/intecoag/IntecoCLI",
|
|
14
22
|
"dependencies": {
|
|
15
23
|
"@azure/identity": "^4.13.1",
|
|
16
|
-
"@azure/storage-blob": "^12.
|
|
24
|
+
"@azure/storage-blob": "^12.32.0",
|
|
17
25
|
"7zip-bin": "^5.2.0",
|
|
18
26
|
"adb-ts": "^6.2.0",
|
|
19
27
|
"application-config": "^3.0.0",
|
|
@@ -25,10 +33,10 @@
|
|
|
25
33
|
"fuzzysort": "^3.1.0",
|
|
26
34
|
"graphql": "^17.0.1",
|
|
27
35
|
"meow": "^14.1.0",
|
|
28
|
-
"
|
|
36
|
+
"mysql2": "^3.22.5",
|
|
29
37
|
"n-readlines": "^3.4.0",
|
|
30
38
|
"node-7z": "^3.0.0",
|
|
31
|
-
"ora": "^9.4.
|
|
39
|
+
"ora": "^9.4.0",
|
|
32
40
|
"prompts": "^2.4.2",
|
|
33
41
|
"properties-parser": "^0.6.0",
|
|
34
42
|
"readline": "^1.3.0",
|
|
@@ -36,17 +44,37 @@
|
|
|
36
44
|
"yaml": "^2.9.0"
|
|
37
45
|
},
|
|
38
46
|
"bin": {
|
|
39
|
-
"inteco": "
|
|
47
|
+
"inteco": "dist/index.js"
|
|
40
48
|
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"README.md"
|
|
52
|
+
],
|
|
41
53
|
"devDependencies": {
|
|
42
|
-
"@commitlint/cli": "^21.
|
|
54
|
+
"@commitlint/cli": "^21.0.2",
|
|
43
55
|
"@commitlint/config-conventional": "^21.0.2",
|
|
56
|
+
"@types/node": "^24.1.0",
|
|
57
|
+
"@types/node-7z": "^2.1.11",
|
|
58
|
+
"@types/prompts": "^2.4.9",
|
|
59
|
+
"@types/properties-parser": "^0.3.3",
|
|
60
|
+
"@types/update-notifier": "^6.0.8",
|
|
61
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
44
62
|
"husky": "^9.1.7",
|
|
45
|
-
"semantic-release": "^25.0.5"
|
|
63
|
+
"semantic-release": "^25.0.5",
|
|
64
|
+
"tsx": "^4.20.6",
|
|
65
|
+
"typescript": "^5.9.2",
|
|
66
|
+
"vitest": "^4.1.9"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=22"
|
|
46
70
|
},
|
|
47
71
|
"release": {
|
|
48
72
|
"branches": [
|
|
49
|
-
"main"
|
|
73
|
+
"main",
|
|
74
|
+
{
|
|
75
|
+
"name": "beta",
|
|
76
|
+
"prerelease": true
|
|
77
|
+
}
|
|
50
78
|
]
|
|
51
79
|
}
|
|
52
80
|
}
|
package/.github/dependabot.yml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
updates:
|
|
3
|
-
- package-ecosystem: "github-actions"
|
|
4
|
-
directory: "/"
|
|
5
|
-
schedule:
|
|
6
|
-
interval: "weekly"
|
|
7
|
-
day: "monday"
|
|
8
|
-
time: "03:00"
|
|
9
|
-
timezone: "UTC"
|
|
10
|
-
- package-ecosystem: "npm"
|
|
11
|
-
directory: "/"
|
|
12
|
-
versioning-strategy: increase
|
|
13
|
-
schedule:
|
|
14
|
-
interval: "weekly"
|
|
15
|
-
day: "monday"
|
|
16
|
-
time: "03:00"
|
|
17
|
-
timezone: "UTC"
|
|
18
|
-
labels:
|
|
19
|
-
- "dependencies"
|
|
20
|
-
groups:
|
|
21
|
-
node-modules:
|
|
22
|
-
patterns:
|
|
23
|
-
- "*"
|
|
24
|
-
open-pull-requests-limit: 10
|
|
25
|
-
commit-message:
|
|
26
|
-
prefix: fix
|
|
27
|
-
prefix-development: chore
|
|
28
|
-
include: scope
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
name: Publish Package Inteco CLI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
id-token: write # Required for OIDC
|
|
10
|
-
contents: write # To create releases
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
publish:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout
|
|
17
|
-
uses: actions/checkout@v7
|
|
18
|
-
with:
|
|
19
|
-
fetch-depth: 0
|
|
20
|
-
- name: Setup Node.js
|
|
21
|
-
uses: actions/setup-node@v6
|
|
22
|
-
with:
|
|
23
|
-
node-version: "lts/*"
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: npm clean-install
|
|
26
|
-
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
|
|
27
|
-
run: npm audit signatures
|
|
28
|
-
- name: Release
|
|
29
|
-
env:
|
|
30
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
-
run: npx semantic-release
|
package/.husky/commit-msg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx --no-install commitlint --edit "$1"
|
package/.vscode/settings.json
DELETED
package/commitlint.config.mjs
DELETED