@signageos/cli 2.3.2 → 2.4.1
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 +53 -19
- package/dist/Applet/Generate/Templates/CHANGELOG.md.template +7 -0
- package/dist/Applet/Generate/Templates/README.md.template +3 -0
- package/dist/Applet/Generate/appletGenerateCommand.js +47 -13
- package/dist/Applet/Start/appletStartCommand.js +1 -1
- package/dist/Applet/Test/Upload/appletTestRunCommand.js +1 -1
- package/dist/Applet/Test/Upload/appletTestRunFacade.js +1 -2
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +5 -5
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js +19 -10
- package/dist/Applet/Upload/appletUploadCommandHelper.js +36 -16
- package/dist/Applet/Upload/appletUploadFacade.js +19 -9
- package/dist/Applet/Upload/appletUploadFacadeHelper.js +19 -10
- package/dist/Applet/appletCommand.d.ts +3 -95
- package/dist/Applet/appletFacade.js +25 -15
- package/dist/Applet/appletServerHelper.js +2 -2
- package/dist/Auth/loginCommand.d.ts +2 -2
- package/dist/Auth/loginCommand.js +19 -9
- package/dist/Cache/tmpCache.js +19 -10
- package/dist/Cli/helper.js +2 -3
- package/dist/Cli/packageVersion.js +24 -15
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.d.ts +10 -0
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.js +39 -0
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.ts +30 -0
- package/dist/Command/Autocomplete/Install/sos-completion.sh +63 -0
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.d.ts +8 -0
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.js +120 -0
- package/dist/Command/Autocomplete/autocompleteCommand.d.ts +22 -0
- package/dist/Command/Autocomplete/autocompleteCommand.js +32 -0
- package/dist/Command/autoComplete.d.ts +4 -0
- package/dist/Command/autoComplete.js +184 -0
- package/dist/Command/commandDefinition.d.ts +9 -9
- package/dist/Command/commandDefinition.js +1 -2
- package/dist/Command/commandProcessor.js +3 -4
- package/dist/Command/globalArgs.js +2 -3
- package/dist/CommandLine/progressBarFactory.d.ts +1 -1
- package/dist/CommandLine/progressBarFactory.js +18 -9
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js +19 -10
- package/dist/CustomScript/customScriptCommand.d.ts +1 -9
- package/dist/CustomScript/customScriptFacade.d.ts +2 -2
- package/dist/CustomScript/customScriptFacade.js +27 -18
- package/dist/Device/Connect/connectCommand.js +1 -1
- package/dist/Device/deviceFacade.js +4 -4
- package/dist/Emulator/createDomain.d.ts +0 -1
- package/dist/Emulator/createDomain.js +18 -9
- package/dist/Emulator/emulatorFacade.js +2 -3
- package/dist/Emulator/emulatorFactory.js +19 -10
- package/dist/Firmware/Upload/firmwareUploadFacade.js +18 -9
- package/dist/Firmware/Upload/firmwareUploadHelper.js +18 -8
- package/dist/Lib/archive.js +18 -9
- package/dist/Lib/childProcess.js +17 -7
- package/dist/Lib/fileSystem.js +21 -12
- package/dist/Lib/git.js +23 -14
- package/dist/Organization/organizationFacade.js +6 -6
- package/dist/RunControl/runControlHelper.js +3 -4
- package/dist/Timer/wait.js +1 -1
- package/dist/helper.d.ts +5 -5
- package/dist/helper.js +13 -13
- package/dist/index.js +4 -1
- package/package.json +43 -46
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.uninstallAutocomplete = exports.OPTION_LIST = void 0;
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const commandDefinition_1 = require("../../commandDefinition");
|
|
49
|
+
exports.OPTION_LIST = [];
|
|
50
|
+
exports.uninstallAutocomplete = (0, commandDefinition_1.createCommandDefinition)({
|
|
51
|
+
name: 'uninstall',
|
|
52
|
+
description: 'Uninstall command auto-completion for bash/zsh shells',
|
|
53
|
+
optionList: exports.OPTION_LIST,
|
|
54
|
+
commands: [],
|
|
55
|
+
run() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
try {
|
|
58
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
59
|
+
if (!homeDir) {
|
|
60
|
+
console.error('Could not determine home directory for auto-completion uninstallation.');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
// Path to the completion script
|
|
64
|
+
const completionFilePath = path.join(homeDir, '.sos-completion.sh');
|
|
65
|
+
// Remove completion script if it exists
|
|
66
|
+
try {
|
|
67
|
+
yield fs.promises.access(completionFilePath);
|
|
68
|
+
yield fs.promises.unlink(completionFilePath);
|
|
69
|
+
console.log(`✅ Removed completion script: ${completionFilePath}`);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error.code === 'ENOENT') {
|
|
73
|
+
console.log(`ℹ️ Completion script not found at: ${completionFilePath}`);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Check shell config files and remove the source line
|
|
80
|
+
const shellConfigFiles = ['.zshrc', '.bashrc', '.bash_profile'];
|
|
81
|
+
const sourceLine = `source ${completionFilePath}`;
|
|
82
|
+
let configModified = false;
|
|
83
|
+
for (const configFile of shellConfigFiles) {
|
|
84
|
+
const configFilePath = path.join(homeDir, configFile);
|
|
85
|
+
if (fs.existsSync(configFilePath)) {
|
|
86
|
+
try {
|
|
87
|
+
let content = fs.readFileSync(configFilePath, 'utf8');
|
|
88
|
+
const originalContent = content;
|
|
89
|
+
// Remove the source line and the comment above it
|
|
90
|
+
const sourceLineWithComment = `# Added by signageOS CLI for tab completion\n${sourceLine}\n`;
|
|
91
|
+
content = content.replace(sourceLineWithComment, '');
|
|
92
|
+
// If the comment and source line pattern doesn't match exactly, try just the source line
|
|
93
|
+
if (content === originalContent) {
|
|
94
|
+
content = content.replace(new RegExp(`${sourceLine}\\n?`, 'g'), '');
|
|
95
|
+
}
|
|
96
|
+
if (content !== originalContent) {
|
|
97
|
+
fs.writeFileSync(configFilePath, content, 'utf8');
|
|
98
|
+
console.log(`✅ Removed source line from ${configFile}`);
|
|
99
|
+
configModified = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
104
|
+
console.error(`Failed to modify ${configFile}:`, errorMessage);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!configModified) {
|
|
109
|
+
console.info(`ℹ️ No shell configuration files were modified`);
|
|
110
|
+
}
|
|
111
|
+
console.log('\nAuto-completion for signageOS CLI has been uninstalled.');
|
|
112
|
+
console.log('You may need to restart your terminal or run "source ~/.bashrc" (or equivalent) for changes to take effect.');
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
116
|
+
console.error('Error uninstalling auto-completion:', errorMessage);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ICommand, OptionList } from '../commandDefinition';
|
|
2
|
+
export declare const OPTION_LIST: readonly [];
|
|
3
|
+
export declare const initializeAutocomplete: (rootCommand: ICommand<string, OptionList>) => void;
|
|
4
|
+
export declare const autocomplete: {
|
|
5
|
+
name: "autocomplete";
|
|
6
|
+
description: string;
|
|
7
|
+
optionList: readonly [];
|
|
8
|
+
commands: ({
|
|
9
|
+
name: "install";
|
|
10
|
+
description: string;
|
|
11
|
+
optionList: readonly [];
|
|
12
|
+
commands: never[];
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
} | {
|
|
15
|
+
name: "uninstall";
|
|
16
|
+
description: string;
|
|
17
|
+
optionList: readonly [];
|
|
18
|
+
commands: never[];
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
})[];
|
|
21
|
+
run(): Promise<never>;
|
|
22
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.autocomplete = exports.initializeAutocomplete = exports.OPTION_LIST = void 0;
|
|
13
|
+
const commandDefinition_1 = require("../commandDefinition");
|
|
14
|
+
const installAutocompleteCommand_1 = require("./Install/installAutocompleteCommand");
|
|
15
|
+
const uninstallAutocompleteCommand_1 = require("./Uninstall/uninstallAutocompleteCommand");
|
|
16
|
+
exports.OPTION_LIST = [];
|
|
17
|
+
// Function to initialize the autocomplete command with the root command reference
|
|
18
|
+
const initializeAutocomplete = (rootCommand) => {
|
|
19
|
+
(0, installAutocompleteCommand_1.setRootCommand)(rootCommand);
|
|
20
|
+
};
|
|
21
|
+
exports.initializeAutocomplete = initializeAutocomplete;
|
|
22
|
+
exports.autocomplete = (0, commandDefinition_1.createCommandDefinition)({
|
|
23
|
+
name: 'autocomplete',
|
|
24
|
+
description: 'Commands for managing CLI auto-completion',
|
|
25
|
+
optionList: exports.OPTION_LIST,
|
|
26
|
+
commands: [installAutocompleteCommand_1.installAutocomplete, uninstallAutocompleteCommand_1.uninstallAutocomplete],
|
|
27
|
+
run() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
throw new Error('Please use a subcommand: install, uninstall');
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ICommand, OptionList } from './commandDefinition';
|
|
2
|
+
export declare function generateCompletionScript(rootCommand: ICommand<string, OptionList>): string;
|
|
3
|
+
export declare function installAutoCompletion(rootCommand: ICommand<string, OptionList>): boolean;
|
|
4
|
+
export declare function setupCompletion(rootCommand: ICommand<string, OptionList>): boolean;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.generateCompletionScript = generateCompletionScript;
|
|
37
|
+
exports.installAutoCompletion = installAutoCompletion;
|
|
38
|
+
exports.setupCompletion = setupCompletion;
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
// Function to extract command structure for auto-completion
|
|
42
|
+
function buildCompletionSchema(command, parentCommand = '', isRoot = true) {
|
|
43
|
+
const commandName = isRoot ? '' : parentCommand ? `${parentCommand} ${command.name}` : command.name;
|
|
44
|
+
const result = {};
|
|
45
|
+
// Add subcommands
|
|
46
|
+
if (command.commands.length > 0) {
|
|
47
|
+
result[commandName] = command.commands.map((cmd) => cmd.name);
|
|
48
|
+
}
|
|
49
|
+
// Add options
|
|
50
|
+
const options = command.optionList.map((opt) => `--${opt.name}`);
|
|
51
|
+
if (options.length > 0) {
|
|
52
|
+
result[`${commandName} options`] = options;
|
|
53
|
+
}
|
|
54
|
+
// Process subcommands with a simpler approach
|
|
55
|
+
for (const subCommand of command.commands) {
|
|
56
|
+
const newParent = commandName || '';
|
|
57
|
+
Object.assign(result, buildCompletionSchema(subCommand, newParent, false));
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
// Move the shell script to a separate file and dynamically read it
|
|
62
|
+
function generateCompletionScript(rootCommand) {
|
|
63
|
+
const commandSchema = buildCompletionSchema(rootCommand);
|
|
64
|
+
const topLevelCommands = commandSchema[''] ? commandSchema[''].join(' ') : '';
|
|
65
|
+
// Read the shell script from the file
|
|
66
|
+
const scriptPath = path.resolve(__dirname, './Autocomplete/Install/sos-completion.sh');
|
|
67
|
+
let script = fs.readFileSync(scriptPath, 'utf8');
|
|
68
|
+
// Generate case statements for each command path
|
|
69
|
+
let commandCases = '';
|
|
70
|
+
for (const cmdPath in commandSchema) {
|
|
71
|
+
if (cmdPath === '') {
|
|
72
|
+
continue;
|
|
73
|
+
} // Skip the top-level commands
|
|
74
|
+
const subcommands = commandSchema[cmdPath] ? commandSchema[cmdPath].join(' ') : '';
|
|
75
|
+
if (subcommands) {
|
|
76
|
+
commandCases += ` "${cmdPath}")\n COMPREPLY=( $(compgen -W "${subcommands}" -- "$cur") )\n return 0\n ;;\n`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// If no command cases were generated, add a comment to make the script valid
|
|
80
|
+
if (!commandCases) {
|
|
81
|
+
commandCases = ' # No subcommands available\n';
|
|
82
|
+
}
|
|
83
|
+
// Replace placeholders in the shell script
|
|
84
|
+
script = script.replace(/\${TOPLEVEL_COMMANDS}/g, topLevelCommands);
|
|
85
|
+
script = script.replace(/ # COMMAND_SCHEMA_CASES will be replaced with actual cases during generation/g, commandCases);
|
|
86
|
+
return script;
|
|
87
|
+
}
|
|
88
|
+
function installAutoCompletion(rootCommand) {
|
|
89
|
+
try {
|
|
90
|
+
const script = generateCompletionScript(rootCommand);
|
|
91
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
92
|
+
if (!homeDir) {
|
|
93
|
+
console.error('Could not determine home directory for auto-completion installation.');
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
// Write completion script
|
|
97
|
+
const completionFilePath = path.join(homeDir, '.sos-completion.sh');
|
|
98
|
+
fs.writeFileSync(completionFilePath, script, 'utf8');
|
|
99
|
+
fs.chmodSync(completionFilePath, '755');
|
|
100
|
+
// Configure shell
|
|
101
|
+
const sourceLine = `source ${completionFilePath}`;
|
|
102
|
+
const configResult = configureShellFile(homeDir, sourceLine);
|
|
103
|
+
// Display message
|
|
104
|
+
displayInstallationMessage(completionFilePath, configResult);
|
|
105
|
+
return configResult.configured;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
109
|
+
console.error('Error installing auto-completion:', errorMessage);
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Helper functions for better organization
|
|
114
|
+
function configureShellFile(homeDir, sourceLine) {
|
|
115
|
+
const shellConfigFiles = ['.zshrc', '.bashrc', '.bash_profile'];
|
|
116
|
+
const activeShell = process.env.SHELL || '';
|
|
117
|
+
// Try to prioritize the current shell's config file
|
|
118
|
+
let orderedConfigFiles = [...shellConfigFiles];
|
|
119
|
+
if (activeShell.includes('zsh')) {
|
|
120
|
+
orderedConfigFiles = ['.zshrc', ...orderedConfigFiles.filter((f) => f !== '.zshrc')];
|
|
121
|
+
}
|
|
122
|
+
else if (activeShell.includes('bash')) {
|
|
123
|
+
orderedConfigFiles = ['.bashrc', '.bash_profile', ...orderedConfigFiles.filter((f) => f !== '.bashrc' && f !== '.bash_profile')];
|
|
124
|
+
}
|
|
125
|
+
for (const configFile of orderedConfigFiles) {
|
|
126
|
+
const configFilePath = path.join(homeDir, configFile);
|
|
127
|
+
try {
|
|
128
|
+
// Skip if file doesn't exist
|
|
129
|
+
if (!fs.existsSync(configFilePath)) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
// Skip if file isn't writable
|
|
133
|
+
const stats = fs.statSync(configFilePath);
|
|
134
|
+
// eslint-disable-next-line no-bitwise
|
|
135
|
+
if ((stats.mode & 0o200) === 0) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const content = fs.readFileSync(configFilePath, 'utf8');
|
|
139
|
+
// Check if already configured
|
|
140
|
+
if (content.includes(sourceLine)) {
|
|
141
|
+
return { configured: true, file: configFile };
|
|
142
|
+
}
|
|
143
|
+
// Add source line
|
|
144
|
+
fs.appendFileSync(configFilePath, `\n# Added by signageOS CLI for tab completion\n${sourceLine}\n`);
|
|
145
|
+
return { configured: true, file: configFile };
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
149
|
+
console.error(`Failed to configure ${configFile}:`, errorMessage);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// No config file found
|
|
153
|
+
return {
|
|
154
|
+
configured: false,
|
|
155
|
+
error: `No suitable shell configuration file found or accessible in ${homeDir}`,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function displayInstallationMessage(completionFilePath, config) {
|
|
159
|
+
// Base message for all scenarios
|
|
160
|
+
const message = ['Auto-completion for signageOS CLI:', `✅ Script installed at: ${completionFilePath}`];
|
|
161
|
+
// Add configuration status
|
|
162
|
+
if (config.configured) {
|
|
163
|
+
message.push(`✅ Source line added to your ${config.file}`);
|
|
164
|
+
message.push('\nTo start using tab completion right away, run:');
|
|
165
|
+
message.push(` source ${completionFilePath}`);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
message.push('❌ Could not automatically configure your shell');
|
|
169
|
+
if (config.error) {
|
|
170
|
+
message.push(` Reason: ${config.error}`);
|
|
171
|
+
}
|
|
172
|
+
message.push('\nTo enable tab completion, add this line to your shell config:');
|
|
173
|
+
message.push(` source ${completionFilePath}`);
|
|
174
|
+
}
|
|
175
|
+
// Add usage examples
|
|
176
|
+
message.push('\nUsage examples:');
|
|
177
|
+
message.push(' sos [TAB] # Show all top-level commands');
|
|
178
|
+
message.push(' sos applet [TAB] # Show all applet subcommands');
|
|
179
|
+
console.log(message.join('\n'));
|
|
180
|
+
}
|
|
181
|
+
// Create a standalone completion setup command
|
|
182
|
+
function setupCompletion(rootCommand) {
|
|
183
|
+
return installAutoCompletion(rootCommand);
|
|
184
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { OptionDefinition as ArgsOptionDefinition } from 'command-line-args';
|
|
2
2
|
import { OptionDefinition as UsageOptionDefinition } from 'command-line-usage';
|
|
3
3
|
import { GENERAL_OPTION_LIST } from '../generalCommand';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export type ICommandOption = Readonly<ArgsOptionDefinition & UsageOptionDefinition>;
|
|
5
|
+
export type OptionList = Readonly<ICommandOption[]>;
|
|
6
|
+
type GetNumberTypeByConstructor<T extends BooleanConstructor | StringConstructor | NumberConstructor> = T extends NumberConstructor ? number : unknown;
|
|
7
|
+
type GetNumOrStrTypeByConstructor<T extends BooleanConstructor | StringConstructor | NumberConstructor> = T extends StringConstructor ? string : GetNumberTypeByConstructor<T>;
|
|
8
|
+
type GetTypeByConstructor<T extends BooleanConstructor | StringConstructor | NumberConstructor> = T extends BooleanConstructor ? boolean : GetNumOrStrTypeByConstructor<T>;
|
|
9
|
+
type ArrayIfMultiple<O, T> = O extends {
|
|
10
10
|
multiple: true;
|
|
11
11
|
} ? T[] : T;
|
|
12
|
-
|
|
13
|
-
export
|
|
12
|
+
type OptionListWithGeneral<OL extends OptionList> = [...typeof GENERAL_OPTION_LIST, ...OL];
|
|
13
|
+
export type CommandLineOptions<OL extends OptionList> = {
|
|
14
14
|
[P in OptionListWithGeneral<OL>[number]['name']]: ArrayIfMultiple<Extract<OptionListWithGeneral<OL>[number], {
|
|
15
15
|
name: P;
|
|
16
16
|
}>, GetTypeByConstructor<Extract<OptionListWithGeneral<OL>[number], {
|
|
17
17
|
name: P;
|
|
18
18
|
}>['type']>> | undefined;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type ICommand<N extends string, OL extends OptionList> = {
|
|
21
21
|
name: N;
|
|
22
22
|
description: string;
|
|
23
23
|
optionList: OL;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCommandDefinition =
|
|
3
|
+
exports.createCommandDefinition = createCommandDefinition;
|
|
4
4
|
function createCommandDefinition(def) {
|
|
5
5
|
return def;
|
|
6
6
|
}
|
|
7
|
-
exports.createCommandDefinition = createCommandDefinition;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.processCommand =
|
|
15
|
+
exports.processCommand = processCommand;
|
|
16
16
|
const debug_1 = __importDefault(require("debug"));
|
|
17
17
|
const chalk_1 = __importDefault(require("chalk"));
|
|
18
18
|
const command_line_usage_1 = __importDefault(require("command-line-usage"));
|
|
@@ -20,8 +20,8 @@ const command_line_args_1 = __importDefault(require("command-line-args"));
|
|
|
20
20
|
const packageVersion_1 = require("../Cli/packageVersion");
|
|
21
21
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
22
22
|
const Debug = (0, debug_1.default)('@signageos/cli:Command:processor');
|
|
23
|
-
function processCommand(
|
|
24
|
-
return __awaiter(this,
|
|
23
|
+
function processCommand(currentCommand_1) {
|
|
24
|
+
return __awaiter(this, arguments, void 0, function* (currentCommand, parentOptionList = [], commandIndex = 0) {
|
|
25
25
|
const nestedOptionList = [...parentOptionList, ...currentCommand.optionList];
|
|
26
26
|
const currentOptions = (0, command_line_args_1.default)(nestedOptionList, { partial: true });
|
|
27
27
|
Debug('process', currentOptions);
|
|
@@ -54,7 +54,6 @@ function processCommand(currentCommand, parentOptionList = [], commandIndex = 0)
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
exports.processCommand = processCommand;
|
|
58
57
|
function printUsage(currentCommand, optionList) {
|
|
59
58
|
(0, log_1.log)('info', chalk_1.default.bold(currentCommand.name));
|
|
60
59
|
(0, log_1.log)('info', ' - ' + chalk_1.default.italic(currentCommand.description), '');
|
|
@@ -3,16 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getGlobalApiUrl = getGlobalApiUrl;
|
|
7
|
+
exports.getGlobalProfile = getGlobalProfile;
|
|
7
8
|
const command_line_args_1 = __importDefault(require("command-line-args"));
|
|
8
9
|
const generalCommand_1 = require("../generalCommand");
|
|
9
10
|
function getGlobalApiUrl() {
|
|
10
11
|
const options = (0, command_line_args_1.default)([generalCommand_1.API_URL_OPTION], { partial: true });
|
|
11
12
|
return options[generalCommand_1.API_URL_OPTION.name];
|
|
12
13
|
}
|
|
13
|
-
exports.getGlobalApiUrl = getGlobalApiUrl;
|
|
14
14
|
function getGlobalProfile() {
|
|
15
15
|
const options = (0, command_line_args_1.default)([generalCommand_1.PROFILE_OPTION], { partial: true });
|
|
16
16
|
return options[generalCommand_1.PROFILE_OPTION.name];
|
|
17
17
|
}
|
|
18
|
-
exports.getGlobalProfile = getGlobalProfile;
|
|
@@ -15,15 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createProgressBar =
|
|
36
|
+
exports.createProgressBar = createProgressBar;
|
|
27
37
|
const cliProgress = __importStar(require("cli-progress"));
|
|
28
38
|
function createProgressBar() {
|
|
29
39
|
const progressBar = new cliProgress.Bar({
|
|
@@ -46,4 +56,3 @@ function createProgressBar() {
|
|
|
46
56
|
},
|
|
47
57
|
};
|
|
48
58
|
}
|
|
49
|
-
exports.createProgressBar = createProgressBar;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,7 +45,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.
|
|
48
|
+
exports.askForParameters = askForParameters;
|
|
49
|
+
exports.downloadBoilerplateCode = downloadBoilerplateCode;
|
|
39
50
|
const chalk_1 = __importDefault(require("chalk"));
|
|
40
51
|
const prompts_1 = __importDefault(require("prompts"));
|
|
41
52
|
const path = __importStar(require("path"));
|
|
@@ -95,7 +106,6 @@ function askForParameters() {
|
|
|
95
106
|
};
|
|
96
107
|
});
|
|
97
108
|
}
|
|
98
|
-
exports.askForParameters = askForParameters;
|
|
99
109
|
/**
|
|
100
110
|
* Downloads the latest version of the boilerplate code from the GitHub repository.
|
|
101
111
|
*/
|
|
@@ -107,4 +117,3 @@ function downloadBoilerplateCode(targetDir) {
|
|
|
107
117
|
yield fs.remove(path.join(targetDir, '.git'));
|
|
108
118
|
});
|
|
109
119
|
}
|
|
110
|
-
exports.downloadBoilerplateCode = downloadBoilerplateCode;
|
|
@@ -15,15 +15,7 @@ export declare const customScript: {
|
|
|
15
15
|
readonly description: "Organization UID";
|
|
16
16
|
}];
|
|
17
17
|
commands: never[];
|
|
18
|
-
run(options: import("../Command/commandDefinition").CommandLineOptions<
|
|
19
|
-
readonly name: "no-default-organization";
|
|
20
|
-
readonly type: BooleanConstructor;
|
|
21
|
-
readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc which were set using command sos organization set-default";
|
|
22
|
-
}, {
|
|
23
|
-
readonly name: "organization-uid";
|
|
24
|
-
readonly type: StringConstructor;
|
|
25
|
-
readonly description: "Organization UID";
|
|
26
|
-
}]>): Promise<void>;
|
|
18
|
+
run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Upload/customScriptUploadCommand").OPTION_LIST>): Promise<void>;
|
|
27
19
|
} | {
|
|
28
20
|
name: "generate";
|
|
29
21
|
description: string;
|
|
@@ -17,7 +17,7 @@ declare const PlatformSchema: z.ZodObject<{
|
|
|
17
17
|
mainFile: string;
|
|
18
18
|
runtime: string;
|
|
19
19
|
}>;
|
|
20
|
-
export
|
|
20
|
+
export type PlatformConfig = z.infer<typeof PlatformSchema>;
|
|
21
21
|
declare const ConfigSchema: z.ZodObject<{
|
|
22
22
|
uid: z.ZodOptional<z.ZodString>;
|
|
23
23
|
name: z.ZodString;
|
|
@@ -72,7 +72,7 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
72
72
|
description?: string | undefined;
|
|
73
73
|
uid?: string | undefined;
|
|
74
74
|
}>;
|
|
75
|
-
export
|
|
75
|
+
export type CustomScriptConfig = z.infer<typeof ConfigSchema>;
|
|
76
76
|
/**
|
|
77
77
|
* Represents archive with Custom Script code for a particular platform
|
|
78
78
|
*/
|