@signageos/cli 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Applet/Generate/Templates/index.css.template +4 -0
- package/dist/Applet/Generate/Templates/index.html.template +12 -0
- package/dist/Applet/Generate/Templates/index.js.template +11 -0
- package/dist/Applet/Generate/Templates/rspack.config.mjs.template +48 -0
- package/dist/Applet/Generate/Templates/tsconfig.js.template +35 -0
- package/dist/Applet/Generate/Templates/webpack.config.js.template +47 -0
- package/dist/Applet/Generate/appletGenerateCommand.d.ts +29 -4
- package/dist/Applet/Generate/appletGenerateCommand.js +204 -142
- package/dist/Applet/Generate/appletGenerateCommand.js.map +1 -1
- package/dist/Applet/appletCommand.d.ts +4 -4
- package/dist/CustomScript/Generate/customScriptGenerateCommand.d.ts +7 -0
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js +77 -0
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +1 -0
- package/dist/CustomScript/Generate/customScriptGenerateFacade.d.ts +13 -0
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js +134 -0
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +1 -0
- package/dist/CustomScript/customScriptCommand.d.ts +8 -2
- package/dist/CustomScript/customScriptCommand.js +2 -1
- package/dist/CustomScript/customScriptCommand.js.map +1 -1
- package/dist/Lib/childProcess.d.ts +7 -0
- package/dist/Lib/childProcess.js +28 -0
- package/dist/Lib/childProcess.js.map +1 -0
- package/dist/Lib/git.d.ts +4 -0
- package/dist/Lib/git.js +109 -0
- package/dist/Lib/git.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.customScriptGenerate = void 0;
|
|
40
|
+
var chalk_1 = require("chalk");
|
|
41
|
+
var log_1 = require("@signageos/sdk/dist/Console/log");
|
|
42
|
+
var commandDefinition_1 = require("../../Command/commandDefinition");
|
|
43
|
+
var customScriptFacade_1 = require("../customScriptFacade");
|
|
44
|
+
var customScriptGenerateFacade_1 = require("./customScriptGenerateFacade");
|
|
45
|
+
var git_1 = require("../../Lib/git");
|
|
46
|
+
exports.customScriptGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
47
|
+
name: 'generate',
|
|
48
|
+
description: 'Generates a local repository for developing a Custom Script',
|
|
49
|
+
optionList: [],
|
|
50
|
+
commands: [],
|
|
51
|
+
run: function () {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
var _a, targetDir, name, description, dangerLevel;
|
|
54
|
+
return __generator(this, function (_b) {
|
|
55
|
+
switch (_b.label) {
|
|
56
|
+
case 0: return [4 /*yield*/, (0, git_1.throwErrorIfGitNotInstalled)()];
|
|
57
|
+
case 1:
|
|
58
|
+
_b.sent();
|
|
59
|
+
return [4 /*yield*/, (0, customScriptGenerateFacade_1.askForParameters)()];
|
|
60
|
+
case 2:
|
|
61
|
+
_a = _b.sent(), targetDir = _a.targetDir, name = _a.name, description = _a.description, dangerLevel = _a.dangerLevel;
|
|
62
|
+
return [4 /*yield*/, (0, customScriptGenerateFacade_1.downloadBoilerplateCode)(targetDir)];
|
|
63
|
+
case 3:
|
|
64
|
+
_b.sent();
|
|
65
|
+
return [4 /*yield*/, (0, customScriptFacade_1.addToConfigFile)(targetDir, { name: name, description: description, dangerLevel: dangerLevel })];
|
|
66
|
+
case 4:
|
|
67
|
+
_b.sent();
|
|
68
|
+
(0, log_1.log)('info', "Custom Script ".concat(chalk_1.default.green(name), " has been generated in ").concat(chalk_1.default.green(targetDir), "."));
|
|
69
|
+
(0, log_1.log)('info', 'Next steps:');
|
|
70
|
+
(0, log_1.log)('info', " - Open the folder ".concat(chalk_1.default.green(targetDir), " and read the ").concat(chalk_1.default.green('README.md'), " file."));
|
|
71
|
+
return [2 /*return*/];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=customScriptGenerateCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customScriptGenerateCommand.js","sourceRoot":"","sources":["../../../src/CustomScript/Generate/customScriptGenerateCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA0B;AAC1B,uDAAsD;AACtD,qEAA0E;AAC1E,4DAAwD;AACxD,2EAAyF;AACzF,qCAA4D;AAE/C,QAAA,oBAAoB,GAAG,IAAA,2CAAuB,EAAC;IAC3D,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,6DAA6D;IAC1E,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,EAAE;IACN,GAAG;;;;;4BACR,qBAAM,IAAA,iCAA2B,GAAE,EAAA;;wBAAnC,SAAmC,CAAC;wBAEkB,qBAAM,IAAA,6CAAgB,GAAE,EAAA;;wBAAxE,KAAgD,SAAwB,EAAtE,SAAS,eAAA,EAAE,IAAI,UAAA,EAAE,WAAW,iBAAA,EAAE,WAAW,iBAAA;wBAEjD,qBAAM,IAAA,oDAAuB,EAAC,SAAS,CAAC,EAAA;;wBAAxC,SAAwC,CAAC;wBACzC,qBAAM,IAAA,oCAAe,EAAC,SAAS,EAAE,EAAE,IAAI,MAAA,EAAE,WAAW,aAAA,EAAE,WAAW,aAAA,EAAE,CAAC,EAAA;;wBAApE,SAAoE,CAAC;wBAErE,IAAA,SAAG,EAAC,MAAM,EAAE,wBAAiB,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,oCAA0B,eAAK,CAAC,KAAK,CAAC,SAAS,CAAC,MAAG,CAAC,CAAC;wBACnG,IAAA,SAAG,EAAC,MAAM,EAAE,aAAa,CAAC,CAAC;wBAC3B,IAAA,SAAG,EAAC,MAAM,EAAE,8BAAuB,eAAK,CAAC,KAAK,CAAC,SAAS,CAAC,2BAAiB,eAAK,CAAC,KAAK,CAAC,WAAW,CAAC,WAAQ,CAAC,CAAC;;;;;KAC5G;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts the user for the parameters needed to generate a custom script.
|
|
3
|
+
*/
|
|
4
|
+
export declare function askForParameters(): Promise<{
|
|
5
|
+
targetDir: any;
|
|
6
|
+
name: any;
|
|
7
|
+
description: any;
|
|
8
|
+
dangerLevel: any;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Downloads the latest version of the boilerplate code from the GitHub repository.
|
|
12
|
+
*/
|
|
13
|
+
export declare function downloadBoilerplateCode(targetDir: string): Promise<void>;
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.downloadBoilerplateCode = exports.askForParameters = void 0;
|
|
40
|
+
var chalk_1 = require("chalk");
|
|
41
|
+
var prompts = require("prompts");
|
|
42
|
+
var path = require("path");
|
|
43
|
+
var fs = require("fs-extra");
|
|
44
|
+
var log_1 = require("@signageos/sdk/dist/Console/log");
|
|
45
|
+
var git_1 = require("../../Lib/git");
|
|
46
|
+
/**
|
|
47
|
+
* Prompts the user for the parameters needed to generate a custom script.
|
|
48
|
+
*/
|
|
49
|
+
function askForParameters() {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
var throwCanceledError, _a, name, description, dangerLevel, targetDir, confirm;
|
|
52
|
+
return __generator(this, function (_b) {
|
|
53
|
+
switch (_b.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
throwCanceledError = function () {
|
|
56
|
+
throw new Error('Custom Script generation was canceled.');
|
|
57
|
+
};
|
|
58
|
+
return [4 /*yield*/, prompts([
|
|
59
|
+
{
|
|
60
|
+
type: 'text',
|
|
61
|
+
name: 'name',
|
|
62
|
+
message: 'Type name',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'text',
|
|
66
|
+
name: 'description',
|
|
67
|
+
message: 'Type description',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'select',
|
|
71
|
+
name: 'dangerLevel',
|
|
72
|
+
message: 'Select danger level',
|
|
73
|
+
choices: [
|
|
74
|
+
{ title: 'Low', value: 'low' },
|
|
75
|
+
{ title: 'Medium', value: 'medium' },
|
|
76
|
+
{ title: 'High', value: 'high' },
|
|
77
|
+
{ title: 'Critical', value: 'critical' },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
], { onCancel: throwCanceledError })];
|
|
81
|
+
case 1:
|
|
82
|
+
_a = _b.sent(), name = _a.name, description = _a.description, dangerLevel = _a.dangerLevel;
|
|
83
|
+
targetDir = name;
|
|
84
|
+
(0, log_1.log)('info', "Generating Custom Script with these parameters:\n" +
|
|
85
|
+
" - Directory: ".concat(chalk_1.default.green(targetDir), "\n") +
|
|
86
|
+
" - Name: ".concat(chalk_1.default.green(name), "\n") +
|
|
87
|
+
" - Description: ".concat(chalk_1.default.green(description), "\n") +
|
|
88
|
+
" - Danger Level: ".concat(chalk_1.default.green(dangerLevel), "\n"));
|
|
89
|
+
return [4 /*yield*/, prompts({
|
|
90
|
+
type: 'confirm',
|
|
91
|
+
name: 'confirm',
|
|
92
|
+
message: 'Confirm',
|
|
93
|
+
})];
|
|
94
|
+
case 2:
|
|
95
|
+
confirm = (_b.sent()).confirm;
|
|
96
|
+
if (!confirm) {
|
|
97
|
+
throwCanceledError();
|
|
98
|
+
}
|
|
99
|
+
return [2 /*return*/, {
|
|
100
|
+
targetDir: targetDir,
|
|
101
|
+
name: name,
|
|
102
|
+
description: description,
|
|
103
|
+
dangerLevel: dangerLevel,
|
|
104
|
+
}];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
exports.askForParameters = askForParameters;
|
|
110
|
+
/**
|
|
111
|
+
* Downloads the latest version of the boilerplate code from the GitHub repository.
|
|
112
|
+
*/
|
|
113
|
+
function downloadBoilerplateCode(targetDir) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
var URL;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
URL = 'https://github.com/signageos/custom-scripts-boilerplate.git';
|
|
120
|
+
return [4 /*yield*/, (0, git_1.cloneGitRepository)(URL, targetDir)];
|
|
121
|
+
case 1:
|
|
122
|
+
_a.sent();
|
|
123
|
+
// we just want the code, not the git history
|
|
124
|
+
return [4 /*yield*/, fs.remove(path.join(targetDir, '.git'))];
|
|
125
|
+
case 2:
|
|
126
|
+
// we just want the code, not the git history
|
|
127
|
+
_a.sent();
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
exports.downloadBoilerplateCode = downloadBoilerplateCode;
|
|
134
|
+
//# sourceMappingURL=customScriptGenerateFacade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customScriptGenerateFacade.js","sourceRoot":"","sources":["../../../src/CustomScript/Generate/customScriptGenerateFacade.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA0B;AAC1B,iCAAmC;AACnC,2BAA6B;AAC7B,6BAA+B;AAC/B,uDAAsD;AACtD,qCAAmD;AAEnD;;GAEG;AACH,SAAsB,gBAAgB;;;;;;oBAC/B,kBAAkB,GAAG;wBAC1B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;oBAC3D,CAAC,CAAC;oBAEyC,qBAAM,OAAO,CACvD;4BACC;gCACC,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,MAAM;gCACZ,OAAO,EAAE,WAAW;6BACpB;4BACD;gCACC,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,aAAa;gCACnB,OAAO,EAAE,kBAAkB;6BAC3B;4BACD;gCACC,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,aAAa;gCACnB,OAAO,EAAE,qBAAqB;gCAC9B,OAAO,EAAE;oCACR,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;oCAC9B,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;oCACpC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;oCAChC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;iCACxC;6BACD;yBACD,EACD,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAChC,EAAA;;oBAzBK,KAAqC,SAyB1C,EAzBO,IAAI,UAAA,EAAE,WAAW,iBAAA,EAAE,WAAW,iBAAA;oBA2BhC,SAAS,GAAG,IAAI,CAAC;oBAEvB,IAAA,SAAG,EACF,MAAM,EACN,mDAAmD;wBAClD,yBAAkB,eAAK,CAAC,KAAK,CAAC,SAAS,CAAC,OAAI;wBAC5C,oBAAa,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAI;wBAClC,2BAAoB,eAAK,CAAC,KAAK,CAAC,WAAW,CAAC,OAAI;wBAChD,4BAAqB,eAAK,CAAC,KAAK,CAAC,WAAW,CAAC,OAAI,CAClD,CAAC;oBAEkB,qBAAM,OAAO,CAAC;4BACjC,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,SAAS;4BACf,OAAO,EAAE,SAAS;yBAClB,CAAC,EAAA;;oBAJM,OAAO,GAAK,CAAA,SAIlB,CAAA,QAJa;oBAMf,IAAI,CAAC,OAAO,EAAE;wBACb,kBAAkB,EAAE,CAAC;qBACrB;oBAED,sBAAO;4BACN,SAAS,WAAA;4BACT,IAAI,MAAA;4BACJ,WAAW,aAAA;4BACX,WAAW,aAAA;yBACX,EAAC;;;;CACF;AA3DD,4CA2DC;AAED;;GAEG;AACH,SAAsB,uBAAuB,CAAC,SAAiB;;;;;;oBACxD,GAAG,GAAG,6DAA6D,CAAC;oBAC1E,qBAAM,IAAA,wBAAkB,EAAC,GAAG,EAAE,SAAS,CAAC,EAAA;;oBAAxC,SAAwC,CAAC;oBAEzC,6CAA6C;oBAC7C,qBAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,EAAA;;oBAD7C,6CAA6C;oBAC7C,SAA6C,CAAC;;;;;CAC9C;AAND,0DAMC"}
|
|
@@ -2,7 +2,7 @@ export declare const customScript: {
|
|
|
2
2
|
name: "custom-script";
|
|
3
3
|
description: string;
|
|
4
4
|
optionList: never[];
|
|
5
|
-
commands: {
|
|
5
|
+
commands: ({
|
|
6
6
|
name: "upload";
|
|
7
7
|
description: string;
|
|
8
8
|
optionList: readonly [{
|
|
@@ -24,6 +24,12 @@ export declare const customScript: {
|
|
|
24
24
|
readonly type: StringConstructor;
|
|
25
25
|
readonly description: "Organization UID";
|
|
26
26
|
}]>): Promise<void>;
|
|
27
|
-
}
|
|
27
|
+
} | {
|
|
28
|
+
name: "generate";
|
|
29
|
+
description: string;
|
|
30
|
+
optionList: never[];
|
|
31
|
+
commands: never[];
|
|
32
|
+
run(): Promise<void>;
|
|
33
|
+
})[];
|
|
28
34
|
run(): Promise<never>;
|
|
29
35
|
};
|
|
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.customScript = void 0;
|
|
40
40
|
var commandDefinition_1 = require("../Command/commandDefinition");
|
|
41
41
|
var customScriptUploadCommand_1 = require("./Upload/customScriptUploadCommand");
|
|
42
|
+
var customScriptGenerateCommand_1 = require("./Generate/customScriptGenerateCommand");
|
|
42
43
|
exports.customScript = (0, commandDefinition_1.createCommandDefinition)({
|
|
43
44
|
name: 'custom-script',
|
|
44
45
|
description: 'Custom Script management',
|
|
45
46
|
optionList: [],
|
|
46
|
-
commands: [customScriptUploadCommand_1.customScriptUpload],
|
|
47
|
+
commands: [customScriptUploadCommand_1.customScriptUpload, customScriptGenerateCommand_1.customScriptGenerate],
|
|
47
48
|
run: function () {
|
|
48
49
|
return __awaiter(this, void 0, void 0, function () {
|
|
49
50
|
return __generator(this, function (_a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customScriptCommand.js","sourceRoot":"","sources":["../../src/CustomScript/customScriptCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAuE;AACvE,gFAAwE;
|
|
1
|
+
{"version":3,"file":"customScriptCommand.js","sourceRoot":"","sources":["../../src/CustomScript/customScriptCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAuE;AACvE,gFAAwE;AACxE,sFAA8E;AAEjE,QAAA,YAAY,GAAG,IAAA,2CAAuB,EAAC;IACnD,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,0BAA0B;IACvC,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,CAAC,8CAAkB,EAAE,kDAAoB,CAAC;IAC9C,GAAG;;;gBACR,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;;;KACnC;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeChildProcess = void 0;
|
|
4
|
+
var child_process = require("child_process");
|
|
5
|
+
/**
|
|
6
|
+
* Execute a child process command
|
|
7
|
+
* @param command
|
|
8
|
+
* @param verbose
|
|
9
|
+
* @returns Promise<string>
|
|
10
|
+
*/
|
|
11
|
+
var executeChildProcess = function (command, verbose) {
|
|
12
|
+
return new Promise(function (resolve, reject) {
|
|
13
|
+
child_process.exec(command, function (error, stdout, stderr) {
|
|
14
|
+
if (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
if (verbose) {
|
|
19
|
+
console.log(stdout);
|
|
20
|
+
console.log(stderr);
|
|
21
|
+
}
|
|
22
|
+
resolve(stdout);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
exports.executeChildProcess = executeChildProcess;
|
|
28
|
+
//# sourceMappingURL=childProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"childProcess.js","sourceRoot":"","sources":["../../src/Lib/childProcess.ts"],"names":[],"mappings":";;;AAAA,6CAA+C;AAE/C;;;;;GAKG;AACI,IAAM,mBAAmB,GAAG,UAAC,OAAe,EAAE,OAAgB;IACpE,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QAClC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,UAAC,KAAK,EAAE,MAAM,EAAE,MAAM;YACjD,IAAI,KAAK,EAAE;gBACV,MAAM,CAAC,KAAK,CAAC,CAAC;aACd;iBAAM;gBACN,IAAI,OAAO,EAAE;oBACZ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;oBACpB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACpB;gBACD,OAAO,CAAC,MAAM,CAAC,CAAC;aAChB;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,mBAAmB,uBAc9B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function machineHasGit(): Promise<boolean>;
|
|
2
|
+
export declare function throwErrorIfGitNotInstalled(): Promise<void>;
|
|
3
|
+
export declare function initGitRepository(relativePath: string): Promise<void>;
|
|
4
|
+
export declare function cloneGitRepository(gitUrl: string, targetDir: string): Promise<void>;
|
package/dist/Lib/git.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.cloneGitRepository = exports.initGitRepository = exports.throwErrorIfGitNotInstalled = exports.machineHasGit = void 0;
|
|
40
|
+
var path = require("path");
|
|
41
|
+
var childProcess_1 = require("./childProcess");
|
|
42
|
+
function machineHasGit() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var result, error_1;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
_a.trys.push([0, 2, , 3]);
|
|
49
|
+
return [4 /*yield*/, (0, childProcess_1.executeChildProcess)('git --version', true)];
|
|
50
|
+
case 1:
|
|
51
|
+
result = _a.sent();
|
|
52
|
+
return [2 /*return*/, result.includes('git version')];
|
|
53
|
+
case 2:
|
|
54
|
+
error_1 = _a.sent();
|
|
55
|
+
return [2 /*return*/, false];
|
|
56
|
+
case 3: return [2 /*return*/];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
exports.machineHasGit = machineHasGit;
|
|
62
|
+
function throwErrorIfGitNotInstalled() {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0: return [4 /*yield*/, machineHasGit()];
|
|
67
|
+
case 1:
|
|
68
|
+
if (!(_a.sent())) {
|
|
69
|
+
throw new Error('Git is not installed on this machine. Please install Git to use this feature.');
|
|
70
|
+
}
|
|
71
|
+
return [2 /*return*/];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.throwErrorIfGitNotInstalled = throwErrorIfGitNotInstalled;
|
|
77
|
+
function initGitRepository(relativePath) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
var absolutePath;
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
switch (_a.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
absolutePath = path.resolve(relativePath);
|
|
84
|
+
return [4 /*yield*/, (0, childProcess_1.executeChildProcess)("git init \"".concat(absolutePath, "\""), false)];
|
|
85
|
+
case 1:
|
|
86
|
+
_a.sent();
|
|
87
|
+
return [2 /*return*/];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
exports.initGitRepository = initGitRepository;
|
|
93
|
+
function cloneGitRepository(gitUrl, targetDir) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
+
var absolutePath;
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
switch (_a.label) {
|
|
98
|
+
case 0:
|
|
99
|
+
absolutePath = path.resolve(targetDir);
|
|
100
|
+
return [4 /*yield*/, (0, childProcess_1.executeChildProcess)("git clone \"".concat(gitUrl, "\" \"").concat(absolutePath, "\""), false)];
|
|
101
|
+
case 1:
|
|
102
|
+
_a.sent();
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
exports.cloneGitRepository = cloneGitRepository;
|
|
109
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/Lib/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA6B;AAC7B,+CAAqD;AAErD,SAAsB,aAAa;;;;;;;oBAElB,qBAAM,IAAA,kCAAmB,EAAC,eAAe,EAAE,IAAI,CAAC,EAAA;;oBAAzD,MAAM,GAAG,SAAgD;oBAC/D,sBAAO,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAC;;;oBAEtC,sBAAO,KAAK,EAAC;;;;;CAEd;AAPD,sCAOC;AAED,SAAsB,2BAA2B;;;;wBAC1C,qBAAM,aAAa,EAAE,EAAA;;oBAA3B,IAAI,CAAC,CAAC,SAAqB,CAAC,EAAE;wBAC7B,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;qBACjG;;;;;CACD;AAJD,kEAIC;AAED,SAAsB,iBAAiB,CAAC,YAAoB;;;;;;oBACrD,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;oBAChD,qBAAM,IAAA,kCAAmB,EAAC,qBAAa,YAAY,OAAG,EAAE,KAAK,CAAC,EAAA;;oBAA9D,SAA8D,CAAC;;;;;CAC/D;AAHD,8CAGC;AAED,SAAsB,kBAAkB,CAAC,MAAc,EAAE,SAAiB;;;;;;oBACnE,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;oBAC7C,qBAAM,IAAA,kCAAmB,EAAC,sBAAc,MAAM,kBAAM,YAAY,OAAG,EAAE,KAAK,CAAC,EAAA;;oBAA3E,SAA2E,CAAC;;;;;CAC5E;AAHD,gDAGC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signageos/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
".env",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"type": "git"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "npx check-engine@latest && tsc",
|
|
16
|
+
"build": "npx check-engine@latest && tsc && npm run build:templates",
|
|
17
|
+
"build:templates": "node tools/include-templates.js",
|
|
17
18
|
"lint:eslint": "eslint --ext .ts,.tsx,.js,.json ./src/ ./tests",
|
|
18
19
|
"lint": "npm run lint:eslint",
|
|
19
20
|
"clean": "rm -rf dist/*",
|