@codeleap/cli 6.3.0 → 7.0.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/dist/commands/configure.js +26 -61
- package/dist/commands/configure.js.map +1 -0
- package/dist/commands/configureSplash/index.js +21 -61
- package/dist/commands/configureSplash/index.js.map +1 -0
- package/dist/commands/configureSplash/utils.js +68 -86
- package/dist/commands/configureSplash/utils.js.map +1 -0
- package/dist/commands/configureTheme/index.js +31 -80
- package/dist/commands/configureTheme/index.js.map +1 -0
- package/dist/commands/configureTheme/types.js +1 -0
- package/dist/commands/configureTheme/types.js.map +1 -0
- package/dist/commands/configureTheme/utils.js +110 -105
- package/dist/commands/configureTheme/utils.js.map +1 -0
- package/dist/commands/convertorWebp.js +93 -189
- package/dist/commands/convertorWebp.js.map +1 -0
- package/dist/commands/createApp.js +24 -62
- package/dist/commands/createApp.js.map +1 -0
- package/dist/commands/createComponent/index.js +54 -88
- package/dist/commands/createComponent/index.js.map +1 -0
- package/dist/commands/createComponent/utils.js +66 -34
- package/dist/commands/createComponent/utils.js.map +1 -0
- package/dist/commands/downloadKeystores.js +11 -47
- package/dist/commands/downloadKeystores.js.map +1 -0
- package/dist/commands/keystoresAndroid.js +6 -40
- package/dist/commands/keystoresAndroid.js.map +1 -0
- package/dist/commands/linguiTranslate.js +64 -195
- package/dist/commands/linguiTranslate.js.map +1 -0
- package/dist/commands/rename.js +49 -110
- package/dist/commands/rename.js.map +1 -0
- package/dist/commands/syncIcons.js +29 -74
- package/dist/commands/syncIcons.js.map +1 -0
- package/dist/constants.js +42 -20
- package/dist/constants.js.map +1 -0
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -0
- package/dist/lib/Command.js +23 -76
- package/dist/lib/Command.js.map +1 -0
- package/dist/lib/android/index.js +1 -0
- package/dist/lib/android/index.js.map +1 -0
- package/dist/lib/android/keystore.js +91 -117
- package/dist/lib/android/keystore.js.map +1 -0
- package/dist/lib/android/rename.js +131 -246
- package/dist/lib/android/rename.js.map +1 -0
- package/dist/lib/android/utils.js +41 -36
- package/dist/lib/android/utils.js.map +1 -0
- package/dist/lib/createApp/common.js +13 -41
- package/dist/lib/createApp/common.js.map +1 -0
- package/dist/lib/createApp/mobile.js +120 -176
- package/dist/lib/createApp/mobile.js.map +1 -0
- package/dist/lib/firebase.js +11 -33
- package/dist/lib/firebase.js.map +1 -0
- package/dist/lib/index.js +4 -3
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/ios/index.js +1 -0
- package/dist/lib/ios/index.js.map +1 -0
- package/dist/lib/ios/rename.js +90 -140
- package/dist/lib/ios/rename.js.map +1 -0
- package/dist/lib/ios/utils.js +21 -10
- package/dist/lib/ios/utils.js.map +1 -0
- package/dist/lib/spinner.js +21 -52
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/utils.js +56 -32
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/walk.js +65 -87
- package/dist/lib/walk.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/misc.js +45 -34
- package/dist/utils/misc.js.map +1 -0
- package/package.json +10 -5
- package/.gitattributes +0 -1
- package/package.json.bak +0 -45
package/dist/constants.js
CHANGED
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
6
|
exports.MOBILE_TEMPLATE_URL = exports.USER_CONFIG = exports.orgName = exports.cliConfigPath = exports.cliDir = exports.cwd = exports.isDev = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const _cwd = process.cwd();
|
|
10
|
+
/**
|
|
11
|
+
* When `true` the CLI redirects its working directory to `../../../cli-test`
|
|
12
|
+
* instead of the real project root. Set `CODELEAP_CLI_DEV_MODE=true` in the
|
|
13
|
+
* environment to enable; evaluated once at module load time.
|
|
14
|
+
*/
|
|
21
15
|
exports.isDev = process.env.CODELEAP_CLI_DEV_MODE == 'true';
|
|
16
|
+
/**
|
|
17
|
+
* Root directory of the target project the CLI is operating on.
|
|
18
|
+
* In dev mode this resolves to `cli-test/` three levels up from the package;
|
|
19
|
+
* in normal mode it is `process.cwd()` at the time the module was first imported.
|
|
20
|
+
*
|
|
21
|
+
* @sideeffect Sets `GOOGLE_APPLICATION_CREDENTIALS` to `<cwd>/gcp-automation.json`
|
|
22
|
+
* immediately after evaluation so that the GCP SDK picks up the right service-account
|
|
23
|
+
* key without any additional configuration.
|
|
24
|
+
*/
|
|
22
25
|
exports.cwd = path_1.default.resolve(exports.isDev ? '../../../cli-test' : path_1.default.join(_cwd, exports.isDev ? 'tests' : ''));
|
|
23
26
|
process.env.GOOGLE_APPLICATION_CREDENTIALS = path_1.default.join(exports.cwd, 'gcp-automation.json');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const isMonorepo = fs_1.default.existsSync(path_1.default.resolve(__dirname, '../../../apps'));
|
|
28
|
+
const projectRoot = path_1.default.resolve(__dirname, '../../../');
|
|
29
|
+
/**
|
|
30
|
+
* Directory from which the CLI binary was invoked (`process.cwd()` at import
|
|
31
|
+
* time, before any `chdir`). Used as the base for config-file resolution.
|
|
32
|
+
*/
|
|
33
|
+
exports.cliDir = _cwd;
|
|
34
|
+
/**
|
|
35
|
+
* Absolute path to `codeleapcli.config.json` that must exist in `cliDir`.
|
|
36
|
+
* All commands except `configure` throw if this file is absent.
|
|
37
|
+
*/
|
|
27
38
|
exports.cliConfigPath = path_1.default.resolve(exports.cliDir, 'codeleapcli.config.json');
|
|
28
|
-
|
|
39
|
+
let userConfig = {};
|
|
29
40
|
try {
|
|
30
41
|
console.log('Reading config', isMonorepo, userConfig);
|
|
31
42
|
userConfig = JSON.parse(fs_1.default.readFileSync(exports.cliConfigPath).toString());
|
|
@@ -34,6 +45,17 @@ catch (e) {
|
|
|
34
45
|
console.error(e);
|
|
35
46
|
}
|
|
36
47
|
exports.orgName = 'codeleap-uk';
|
|
37
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Merged runtime configuration. Always contains `SHELL: true` as a fallback
|
|
50
|
+
* so callers can rely on the key being present even when the config file is
|
|
51
|
+
* missing or malformed. Keys from `codeleapcli.config.json` override the
|
|
52
|
+
* defaults.
|
|
53
|
+
*/
|
|
54
|
+
exports.USER_CONFIG = Object.assign({ SHELL: true }, userConfig);
|
|
38
55
|
console.log('Current config ->', exports.USER_CONFIG);
|
|
39
|
-
|
|
56
|
+
/**
|
|
57
|
+
* SSH clone URL for the canonical CodeLeap mobile template repository.
|
|
58
|
+
* The caller's environment must have SSH access to `github.com/codeleap-uk`.
|
|
59
|
+
*/
|
|
60
|
+
exports.MOBILE_TEMPLATE_URL = `git@github.com:${exports.orgName}/mobile-template.git`;
|
|
61
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,4CAAmB;AAInB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;AAE1B;;;;GAIG;AACU,QAAA,KAAK,GA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AAE7C;;;GAGG;AACU,QAAA,mBAAmB,GAAG,kBAAkB,eAAO,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const cleye_1 = require("cleye");
|
|
5
|
+
const configure_1 = require("./commands/configure");
|
|
6
|
+
const createApp_1 = require("./commands/createApp");
|
|
7
|
+
const downloadKeystores_1 = require("./commands/downloadKeystores");
|
|
8
|
+
const keystoresAndroid_1 = require("./commands/keystoresAndroid");
|
|
9
|
+
const rename_1 = require("./commands/rename");
|
|
10
|
+
const syncIcons_1 = require("./commands/syncIcons");
|
|
11
|
+
const convertorWebp_1 = require("./commands/convertorWebp");
|
|
12
|
+
const configureTheme_1 = require("./commands/configureTheme");
|
|
13
|
+
const linguiTranslate_1 = require("./commands/linguiTranslate");
|
|
14
|
+
const configureSplash_1 = require("./commands/configureSplash");
|
|
15
|
+
const createComponent_1 = require("./commands/createComponent");
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
|
-
|
|
17
|
+
const packageJson = require('../package.json');
|
|
18
18
|
(0, cleye_1.cli)({
|
|
19
19
|
name: 'codeleap',
|
|
20
20
|
commands: [
|
|
@@ -32,3 +32,4 @@ var packageJson = require('../package.json');
|
|
|
32
32
|
],
|
|
33
33
|
version: packageJson.version,
|
|
34
34
|
});
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,iCAA2B;AAC3B,oDAAuD;AACvD,oDAAuD;AACvD,oEAAgE;AAChE,kEAAgE;AAChE,8CAAuD;AACvD,oDAAuD;AACvD,4DAA+D;AAC/D,8DAAiE;AACjE,gEAAmE;AACnE,gEAAmE;AACnE,gEAAmE;AAEnE,8DAA8D;AAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AAE9C,IAAA,WAAG,EAAC;IACF,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE;QACR,wCAAsB;QACtB,qCAAkB;QAClB,4BAAmB;QACnB,4BAAgB;QAChB,4BAAgB;QAChB,qCAAiB;QACjB,4BAAgB;QAChB,oCAAoB;QACpB,sCAAqB;QACrB,wCAAsB;QACtB,wCAAsB;KACvB;IACD,OAAO,EAAE,WAAW,CAAC,OAAO;CAC7B,CAAC,CAAA"}
|
package/dist/lib/Command.js
CHANGED
|
@@ -8,87 +8,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
-
if (ar || !(i in from)) {
|
|
57
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
-
ar[i] = from[i];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
-
};
|
|
63
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
13
|
};
|
|
66
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
15
|
exports.codeleapCommand = void 0;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
16
|
+
const cleye_1 = require("cleye");
|
|
17
|
+
const figlet_1 = __importDefault(require("figlet"));
|
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
+
const utils_1 = require("./utils");
|
|
20
|
+
const constants_1 = require("../constants");
|
|
21
|
+
/**
|
|
22
|
+
* Drop-in replacement for `cleye`'s `command` that guards every command with
|
|
23
|
+
* two pre-flight checks:
|
|
24
|
+
* 1. Prints the Codeleap ASCII banner so every invocation is visually
|
|
25
|
+
* identifiable in the terminal.
|
|
26
|
+
* 2. Verifies that `codeleapcli.config.json` exists before executing the
|
|
27
|
+
* callback, throwing with an actionable message when it is absent.
|
|
28
|
+
* The `configure` command is exempt from this guard because it is
|
|
29
|
+
* responsible for creating the file in the first place.
|
|
30
|
+
*/
|
|
31
|
+
const codeleapCommand = (opts, callback) => {
|
|
32
|
+
return (0, cleye_1.command)(opts, (...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
console.log(chalk_1.default.blue(figlet_1.default.textSync('Codeleap')));
|
|
34
|
+
if (opts.name !== 'configure' && !utils_1.fs.existsSync(constants_1.cliConfigPath)) {
|
|
35
|
+
throw new Error(`Could not find a configuration file at ${constants_1.cliConfigPath}. Please run 'codeleap configure' to start setup`);
|
|
78
36
|
}
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
switch (_a.label) {
|
|
82
|
-
case 0:
|
|
83
|
-
console.log(chalk_1.default.blue(figlet_1.default.textSync('Codeleap')));
|
|
84
|
-
if (opts.name !== 'configure' && !utils_1.fs.existsSync(constants_1.cliConfigPath)) {
|
|
85
|
-
throw new Error("Could not find a configuration file at ".concat(constants_1.cliConfigPath, ". Please run 'codeleap configure' to start setup"));
|
|
86
|
-
}
|
|
87
|
-
return [4 /*yield*/, callback.apply(void 0, __spreadArray([], __read(args), false))];
|
|
88
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
});
|
|
37
|
+
return yield callback(...args);
|
|
38
|
+
}));
|
|
93
39
|
};
|
|
94
40
|
exports.codeleapCommand = codeleapCommand;
|
|
41
|
+
//# sourceMappingURL=Command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Command.js","sourceRoot":"","sources":["../../src/lib/Command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAA+B;AAC/B,oDAA2B;AAC3B,kDAAyB;AACzB,mCAA4B;AAC5B,4CAA4C;AAE5C;;;;;;;;;GASG;AACI,MAAM,eAAe,GAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;IAChE,OAAO,IAAA,eAAO,EAAC,IAAI,EAAE,CAAO,GAAG,IAAI,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,gBAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAEpD,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,UAAE,CAAC,UAAU,CAAC,yBAAa,CAAC,EAAE,CAAC;YAC/D,MAAM,IAAI,KAAK,CAAC,0CAA0C,yBAAa,kDAAkD,CAAC,CAAA;QAC5H,CAAC;QAED,OAAO,MAAM,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAA;IAChC,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAA;AAVY,QAAA,eAAe,mBAU3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/android/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,0CAAuB"}
|
|
@@ -8,141 +8,115 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
15
|
exports.generateReleaseKeystore = exports.AndroidConfigFile = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
const lib_1 = require("../../lib");
|
|
18
|
+
const generate_password_1 = __importDefault(require("generate-password"));
|
|
19
|
+
const constants_1 = require("../../constants");
|
|
20
|
+
/**
|
|
21
|
+
* JSON-backed store for keystore credentials. Reads `path` on construction if
|
|
22
|
+
* the file already exists; every `setKey` call persists the full updated state
|
|
23
|
+
* back to disk immediately.
|
|
24
|
+
*/
|
|
25
|
+
class AndroidConfigFile {
|
|
26
|
+
constructor(path) {
|
|
49
27
|
this.path = path;
|
|
50
28
|
this.data = {};
|
|
51
29
|
if (utils_1.fs.existsSync(path)) {
|
|
52
30
|
this.data = JSON.parse(utils_1.fs.readFileSync(path).toString());
|
|
53
31
|
}
|
|
54
32
|
}
|
|
55
|
-
|
|
56
|
-
|
|
33
|
+
setKey(key, value) {
|
|
34
|
+
const { keyAlias, keyPassword, storePassword } = value;
|
|
57
35
|
this.data[key] = {
|
|
58
|
-
keyAlias
|
|
59
|
-
keyPassword: keyPassword,
|
|
60
|
-
storePassword: storePassword,
|
|
36
|
+
keyAlias, keyPassword, storePassword,
|
|
61
37
|
};
|
|
62
38
|
this.save();
|
|
63
|
-
}
|
|
64
|
-
|
|
39
|
+
}
|
|
40
|
+
save() {
|
|
65
41
|
utils_1.fs.writeFileSync(this.path, JSON.stringify(this.data, null, 2));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
}());
|
|
42
|
+
}
|
|
43
|
+
}
|
|
69
44
|
exports.AndroidConfigFile = AndroidConfigFile;
|
|
45
|
+
/**
|
|
46
|
+
* Generates a PKCS12 keystore via `keytool` in `_cwd`, using a
|
|
47
|
+
* cryptographically random 26-character password for both the store and the
|
|
48
|
+
* key entry. The validity period is 11 000 days (~30 years).
|
|
49
|
+
*
|
|
50
|
+
* @sideeffect Writes `<type>.keystore` to `_cwd`.
|
|
51
|
+
* @returns Credentials object including the generated password and keystore filename.
|
|
52
|
+
*/
|
|
70
53
|
function genKeystore(type_1) {
|
|
71
|
-
return __awaiter(this, arguments, void 0, function (type, _cwd) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
lowercase: true,
|
|
80
|
-
numbers: true,
|
|
81
|
-
strict: true,
|
|
82
|
-
symbols: true,
|
|
83
|
-
uppercase: true,
|
|
84
|
-
});
|
|
85
|
-
console.log(_cwd);
|
|
86
|
-
alias = type;
|
|
87
|
-
fileName = "".concat(type, ".keystore");
|
|
88
|
-
return [4 /*yield*/, (0, lib_1.subprocess)('Generating keystore', (0, utils_1.findExecutable)('keytool'), [
|
|
89
|
-
'-genkeypair ',
|
|
90
|
-
'-v',
|
|
91
|
-
'-storetype',
|
|
92
|
-
'PKCS12',
|
|
93
|
-
'-keystore',
|
|
94
|
-
fileName,
|
|
95
|
-
'-alias',
|
|
96
|
-
alias,
|
|
97
|
-
'-keyalg',
|
|
98
|
-
'RSA',
|
|
99
|
-
'-keysize',
|
|
100
|
-
'2048',
|
|
101
|
-
'-storepass',
|
|
102
|
-
"\"".concat(pass, "\""),
|
|
103
|
-
'-keypass',
|
|
104
|
-
"\"".concat(pass, "\""),
|
|
105
|
-
'-validity',
|
|
106
|
-
'11000',
|
|
107
|
-
'-dname',
|
|
108
|
-
'CN=Victor Rothberg, OU=Development, O=Codeleap, L=London, ST=Greater London, C=GB',
|
|
109
|
-
], {
|
|
110
|
-
cwd: _cwd
|
|
111
|
-
})];
|
|
112
|
-
case 1:
|
|
113
|
-
_a.sent();
|
|
114
|
-
return [2 /*return*/, {
|
|
115
|
-
'storePassword': pass,
|
|
116
|
-
'keyAlias': alias,
|
|
117
|
-
'keyPassword': pass,
|
|
118
|
-
'keyname': fileName,
|
|
119
|
-
}];
|
|
120
|
-
}
|
|
54
|
+
return __awaiter(this, arguments, void 0, function* (type, _cwd = constants_1.cwd) {
|
|
55
|
+
const pass = generate_password_1.default.generate({
|
|
56
|
+
length: 26,
|
|
57
|
+
lowercase: true,
|
|
58
|
+
numbers: true,
|
|
59
|
+
strict: true,
|
|
60
|
+
symbols: true,
|
|
61
|
+
uppercase: true,
|
|
121
62
|
});
|
|
63
|
+
console.log(_cwd);
|
|
64
|
+
const alias = type;
|
|
65
|
+
const fileName = `${type}.keystore`;
|
|
66
|
+
yield (0, lib_1.subprocess)('Generating keystore', (0, utils_1.findExecutable)('keytool'), [
|
|
67
|
+
'-genkeypair ',
|
|
68
|
+
'-v',
|
|
69
|
+
'-storetype',
|
|
70
|
+
'PKCS12',
|
|
71
|
+
'-keystore',
|
|
72
|
+
fileName,
|
|
73
|
+
'-alias',
|
|
74
|
+
alias,
|
|
75
|
+
'-keyalg',
|
|
76
|
+
'RSA',
|
|
77
|
+
'-keysize',
|
|
78
|
+
'2048',
|
|
79
|
+
'-storepass',
|
|
80
|
+
`"${pass}"`,
|
|
81
|
+
'-keypass',
|
|
82
|
+
`"${pass}"`,
|
|
83
|
+
'-validity',
|
|
84
|
+
'11000',
|
|
85
|
+
'-dname',
|
|
86
|
+
'CN=Victor Rothberg, OU=Development, O=Codeleap, L=London, ST=Greater London, C=GB',
|
|
87
|
+
], {
|
|
88
|
+
cwd: _cwd
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
'storePassword': pass,
|
|
92
|
+
'keyAlias': alias,
|
|
93
|
+
'keyPassword': pass,
|
|
94
|
+
'keyname': fileName,
|
|
95
|
+
};
|
|
122
96
|
});
|
|
123
97
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}); };
|
|
98
|
+
/**
|
|
99
|
+
* Generates a release keystore for an Android project, then writes its
|
|
100
|
+
* credentials to `app/keystores/config.json`.
|
|
101
|
+
*
|
|
102
|
+
* Idempotent: skips generation if `app/keystores/release.keystore` already
|
|
103
|
+
* exists. The caller is instructed (via stdout) to upload the keystore file
|
|
104
|
+
* to 1Password with the JSON credentials in the notes field.
|
|
105
|
+
*/
|
|
106
|
+
const generateReleaseKeystore = (androidFolder) => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
|
+
const keystoresDir = lib_1.path.join(androidFolder || constants_1.cwd, 'app', 'keystores');
|
|
108
|
+
if (utils_1.fs.existsSync(lib_1.path.join(keystoresDir, 'release.keystore'))) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const releaseCredentials = yield genKeystore('release', keystoresDir);
|
|
112
|
+
const configFile = new AndroidConfigFile(lib_1.path.join(keystoresDir, 'config.json'));
|
|
113
|
+
configFile.setKey(releaseCredentials.keyname, releaseCredentials);
|
|
114
|
+
const log = [
|
|
115
|
+
`Generated ${releaseCredentials.keyname} at ${keystoresDir}.`,
|
|
116
|
+
`Upload this file as a document to 1Password, and add the following to it's "notes" section`,
|
|
117
|
+
JSON.stringify(configFile.data, null, 1),
|
|
118
|
+
].join('\n');
|
|
119
|
+
console.log(log);
|
|
120
|
+
});
|
|
148
121
|
exports.generateReleaseKeystore = generateReleaseKeystore;
|
|
122
|
+
//# sourceMappingURL=keystore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystore.js","sourceRoot":"","sources":["../../../src/lib/android/keystore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oCAA6C;AAC7C,mCAA4C;AAC5C,0EAAyC;AACzC,+CAAkD;AASlD;;;;GAIG;AACH,MAAa,iBAAiB;IAG1B,YAAmB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAF/B,SAAI,GAAG,EAAE,CAAA;QAIP,IAAI,UAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC1D,CAAC;IAEH,CAAC;IAED,MAAM,CAAC,GAAU,EAAE,KAA0B;QAC3C,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,KAAK,CAAA;QACtD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;YACf,QAAQ,EAAE,WAAW,EAAE,aAAa;SACrC,CAAA;QACD,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;IAED,IAAI;QACF,UAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CA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