@codeleap/cli 2.4.4 → 2.4.6
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 +0 -1
- package/dist/commands/createApp.js +10 -8
- package/dist/commands/createStyleSheets.js +90 -0
- package/dist/commands/downloadKeystores.js +68 -0
- package/dist/commands/keystoresAndroid.js +2 -73
- package/dist/commands/rename.js +0 -1
- package/dist/constants.js +13 -2
- package/dist/index.js +8 -1
- package/dist/lib/android/keystore.js +122 -1
- package/dist/lib/android/rename.js +21 -20
- package/dist/lib/createApp/common.js +1 -1
- package/dist/lib/createApp/mobile.js +117 -143
- package/dist/lib/firebase.js +16 -18
- package/dist/lib/index.js +1 -0
- package/dist/lib/ios/rename.js +4 -5
- package/dist/lib/utils.js +36 -27
- package/dist/lib/walk.js +5 -5
- package/package.json +1 -1
|
@@ -37,7 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.configureCommand = void 0;
|
|
40
|
-
// import { waitFor } from '@codeleap/common'
|
|
41
40
|
var Command_1 = require("../lib/Command");
|
|
42
41
|
var lib_1 = require("../lib");
|
|
43
42
|
require("../lib/firebase");
|
|
@@ -37,7 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.createAppCommand = void 0;
|
|
40
|
-
// import { waitFor } from '@codeleap/common'
|
|
41
40
|
var Command_1 = require("../lib/Command");
|
|
42
41
|
var lib_1 = require("../lib");
|
|
43
42
|
require("../lib/firebase");
|
|
@@ -77,14 +76,17 @@ exports.createAppCommand = (0, Command_1.codeleapCommand)({
|
|
|
77
76
|
})];
|
|
78
77
|
case 1:
|
|
79
78
|
answer = _a.sent();
|
|
80
|
-
if (answer.Platform === 'Web')
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
if (!(answer.Platform === 'Web')) return [3 /*break*/, 2];
|
|
80
|
+
return [3 /*break*/, 4];
|
|
81
|
+
case 2:
|
|
82
|
+
if (!(answer.Platform === 'Mobile')) return [3 /*break*/, 4];
|
|
83
|
+
return [4 /*yield*/, (0, lib_1.createMobileApp)({
|
|
84
84
|
name: appName,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
})];
|
|
86
|
+
case 3:
|
|
87
|
+
_a.sent();
|
|
88
|
+
_a.label = 4;
|
|
89
|
+
case 4: return [2 /*return*/];
|
|
88
90
|
}
|
|
89
91
|
});
|
|
90
92
|
}); });
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// // import { DEFAULT_STYLES } from '@codeleap/common'
|
|
2
|
+
// import fs from 'fs'
|
|
3
|
+
// import nodePath from 'path'
|
|
4
|
+
// const exists = (path) => {
|
|
5
|
+
// try {
|
|
6
|
+
// const fileStat = fs.statSync(path)
|
|
7
|
+
// return fileStat
|
|
8
|
+
// } catch (e) {
|
|
9
|
+
// return false
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
12
|
+
// const components = Object.keys(DEFAULT_STYLES).filter(
|
|
13
|
+
// (k) => Object.keys(DEFAULT_STYLES[k]).length > 0,
|
|
14
|
+
// )
|
|
15
|
+
// const DEFAULT_PATH = `${process.cwd()}/src/app/stylesheets/`
|
|
16
|
+
// const stylesPath = nodePath.resolve(process.argv?.[3] || DEFAULT_PATH)
|
|
17
|
+
// const component = process.argv?.[2] || '--all'
|
|
18
|
+
// const componentList = component === '--all' ? components : component.split(',')
|
|
19
|
+
// if (!stylesPath) {
|
|
20
|
+
// console.warn('You must supply a path for the styles eg: ' + DEFAULT_PATH)
|
|
21
|
+
// process.exit(1)
|
|
22
|
+
// }
|
|
23
|
+
// const fileData = exists(stylesPath)
|
|
24
|
+
// if (!fileData || !fileData.isDirectory()) {
|
|
25
|
+
// console.warn(
|
|
26
|
+
// `Styles path ${stylesPath} either doesn't exist or is not a directory`,
|
|
27
|
+
// )
|
|
28
|
+
// process.exit(1)
|
|
29
|
+
// }
|
|
30
|
+
// const existingFiles = fs
|
|
31
|
+
// .readdirSync(stylesPath, {
|
|
32
|
+
// withFileTypes: true,
|
|
33
|
+
// })
|
|
34
|
+
// .filter((f) => !f.isDirectory())
|
|
35
|
+
// .map((p) => p.name)
|
|
36
|
+
// const { validFiles, invalidFiles } = componentList.reduce(
|
|
37
|
+
// (acc, cp) => {
|
|
38
|
+
// if (
|
|
39
|
+
// !existingFiles.includes(`${cp}.ts`) &&
|
|
40
|
+
// !existingFiles.includes(`${cp}.tsx`)
|
|
41
|
+
// ) {
|
|
42
|
+
// return {
|
|
43
|
+
// ...acc,
|
|
44
|
+
// validFiles: [...acc.validFiles, cp],
|
|
45
|
+
// }
|
|
46
|
+
// } else {
|
|
47
|
+
// return {
|
|
48
|
+
// ...acc,
|
|
49
|
+
// invalidFiles: [...acc.invalidFiles, cp],
|
|
50
|
+
// }
|
|
51
|
+
// }
|
|
52
|
+
// },
|
|
53
|
+
// {
|
|
54
|
+
// validFiles: [],
|
|
55
|
+
// invalidFiles: [],
|
|
56
|
+
// },
|
|
57
|
+
// )
|
|
58
|
+
// if (invalidFiles.length > 0) {
|
|
59
|
+
// console.log(
|
|
60
|
+
// `Ignoring StyleSheets ${invalidFiles.join(
|
|
61
|
+
// ', ',
|
|
62
|
+
// )} to not overwrite existing files`,
|
|
63
|
+
// )
|
|
64
|
+
// }
|
|
65
|
+
// if (validFiles.length < 1) {
|
|
66
|
+
// console.log('No StyleSheets to create. Exiting')
|
|
67
|
+
// process.exit(0)
|
|
68
|
+
// }
|
|
69
|
+
// console.log(`Creating StyleSheets:\n\n${validFiles.join(' \n')}`)
|
|
70
|
+
// const template = `
|
|
71
|
+
// import { __CP__Composition } from '@codeleap/common'
|
|
72
|
+
// import { variantProvider } from '../theme'
|
|
73
|
+
// const create__CP__Style = variantProvider.createVariantFactory<__CP__Composition>()
|
|
74
|
+
// const defaultStyles = variantProvider.getDefaultVariants('__CP__')
|
|
75
|
+
// export const App__CP__Styles = {
|
|
76
|
+
// ...defaultStyles,
|
|
77
|
+
// default: create__CP__Style((theme) => ({
|
|
78
|
+
// ...defaultStyles.default,
|
|
79
|
+
// })),
|
|
80
|
+
// }
|
|
81
|
+
// `
|
|
82
|
+
// validFiles.forEach((f) => {
|
|
83
|
+
// const fullPath = nodePath.join(stylesPath, `${f}.ts`)
|
|
84
|
+
// const content = template.replace(/__CP__/g, f)
|
|
85
|
+
// return fs.writeFileSync(fullPath, content, {
|
|
86
|
+
// encoding: 'utf-8',
|
|
87
|
+
// })
|
|
88
|
+
// })
|
|
89
|
+
// console.log(`\nCreated ${validFiles.length} stylesheets at ${stylesPath}.\n`)
|
|
90
|
+
// console.log(`Happy Styling!`)
|
|
@@ -0,0 +1,68 @@
|
|
|
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.downloadKeystores = void 0;
|
|
40
|
+
// import { waitFor } from '@codeleap/common'
|
|
41
|
+
var constants_1 = require("../constants");
|
|
42
|
+
var lib_1 = require("../lib");
|
|
43
|
+
var Command_1 = require("../lib/Command");
|
|
44
|
+
exports.downloadKeystores = (0, Command_1.codeleapCommand)({
|
|
45
|
+
name: 'download-keystores',
|
|
46
|
+
parameters: [
|
|
47
|
+
'[branch]'
|
|
48
|
+
],
|
|
49
|
+
}, function (_a) {
|
|
50
|
+
var _ = _a._;
|
|
51
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
+
var dir;
|
|
53
|
+
return __generator(this, function (_b) {
|
|
54
|
+
switch (_b.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
dir = lib_1.path.join(constants_1.cwd, 'android', 'app', 'keystores');
|
|
57
|
+
lib_1.fs.rmSync(dir, {
|
|
58
|
+
recursive: true,
|
|
59
|
+
force: true
|
|
60
|
+
});
|
|
61
|
+
return [4 /*yield*/, lib_1.git.raw('clone', 'git@github.com:codeleap-uk/keystores-android.git', '-b', _.branch, dir)];
|
|
62
|
+
case 1:
|
|
63
|
+
_b.sent();
|
|
64
|
+
return [2 /*return*/];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -35,72 +35,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
39
|
exports.generateReleaseKey = void 0;
|
|
43
|
-
// import { waitFor } from '@codeleap/common'
|
|
44
40
|
var Command_1 = require("../lib/Command");
|
|
45
|
-
var lib_1 = require("../lib");
|
|
46
|
-
var generate_password_1 = __importDefault(require("generate-password"));
|
|
47
41
|
var keystore_1 = require("../lib/android/keystore");
|
|
48
|
-
var constants_1 = require("../constants");
|
|
49
|
-
function genKeystore(type) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
var pass, alias, keystoresDir, fileName;
|
|
52
|
-
return __generator(this, function (_a) {
|
|
53
|
-
switch (_a.label) {
|
|
54
|
-
case 0:
|
|
55
|
-
pass = generate_password_1.default.generate({
|
|
56
|
-
length: 26,
|
|
57
|
-
lowercase: true,
|
|
58
|
-
numbers: true,
|
|
59
|
-
strict: true,
|
|
60
|
-
symbols: true,
|
|
61
|
-
uppercase: true,
|
|
62
|
-
});
|
|
63
|
-
alias = type;
|
|
64
|
-
keystoresDir = lib_1.path.join(constants_1.cwd, 'android', 'app', 'keystores');
|
|
65
|
-
fileName = "".concat(type, ".keystore");
|
|
66
|
-
return [4 /*yield*/, (0, lib_1.subprocess)('Generating keystore', '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: keystoresDir,
|
|
89
|
-
})];
|
|
90
|
-
case 1:
|
|
91
|
-
_a.sent();
|
|
92
|
-
return [2 /*return*/, {
|
|
93
|
-
'storePassword': pass,
|
|
94
|
-
'keyAlias': alias,
|
|
95
|
-
'keyPassword': pass,
|
|
96
|
-
'file': lib_1.path.join(keystoresDir, fileName),
|
|
97
|
-
'keyname': fileName,
|
|
98
|
-
keystoresDir: keystoresDir,
|
|
99
|
-
}];
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
42
|
exports.generateReleaseKey = (0, Command_1.codeleapCommand)({
|
|
105
43
|
name: 'keystores-android',
|
|
106
44
|
parameters: [],
|
|
@@ -108,20 +46,11 @@ exports.generateReleaseKey = (0, Command_1.codeleapCommand)({
|
|
|
108
46
|
}, function (_a) {
|
|
109
47
|
var _ = _a._;
|
|
110
48
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
-
var releaseCredentials, configFile, log;
|
|
112
49
|
return __generator(this, function (_b) {
|
|
113
50
|
switch (_b.label) {
|
|
114
|
-
case 0: return [4 /*yield*/,
|
|
51
|
+
case 0: return [4 /*yield*/, (0, keystore_1.generateReleaseKeystore)()];
|
|
115
52
|
case 1:
|
|
116
|
-
|
|
117
|
-
configFile = new keystore_1.AndroidConfigFile(lib_1.path.join(releaseCredentials.keystoresDir, 'config.json'));
|
|
118
|
-
configFile.setKey(releaseCredentials.keyname, releaseCredentials);
|
|
119
|
-
log = [
|
|
120
|
-
"Generated ".concat(releaseCredentials.keyname, " at ").concat(releaseCredentials.keystoresDir, "."),
|
|
121
|
-
"Upload this file as a document to 1Password, and add the following to it's \"notes\" section",
|
|
122
|
-
JSON.stringify(configFile.data, null, 1),
|
|
123
|
-
].join('\n');
|
|
124
|
-
console.log(log);
|
|
53
|
+
_b.sent();
|
|
125
54
|
return [2 /*return*/];
|
|
126
55
|
}
|
|
127
56
|
});
|
package/dist/commands/rename.js
CHANGED
|
@@ -51,7 +51,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.renameMobileCommand = void 0;
|
|
54
|
-
// import { waitFor } from '@codeleap/common'
|
|
55
54
|
var Command_1 = require("../lib/Command");
|
|
56
55
|
var spinner_1 = require("../lib/spinner");
|
|
57
56
|
var fs_1 = __importDefault(require("fs"));
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
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
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -9,7 +20,7 @@ var fs_1 = __importDefault(require("fs"));
|
|
|
9
20
|
var os_1 = __importDefault(require("os"));
|
|
10
21
|
var _cwd = process.cwd();
|
|
11
22
|
exports.isDev = process.env.CODELEAP_CLI_DEV_MODE == 'true';
|
|
12
|
-
exports.cwd = exports.isDev ? '
|
|
23
|
+
exports.cwd = path_1.default.resolve(exports.isDev ? '../../../cli-test' : path_1.default.join(_cwd, exports.isDev ? 'tests' : ''));
|
|
13
24
|
process.env.GOOGLE_APPLICATION_CREDENTIALS = path_1.default.join(exports.cwd, 'gcp-automation.json');
|
|
14
25
|
exports.cliConfigPath = path_1.default.resolve(os_1.default.homedir(), '.codeleapcli.json');
|
|
15
26
|
var _userConf = {};
|
|
@@ -19,5 +30,5 @@ try {
|
|
|
19
30
|
catch (e) {
|
|
20
31
|
}
|
|
21
32
|
exports.orgName = 'codeleap-uk';
|
|
22
|
-
exports.USER_CONFIG = _userConf;
|
|
33
|
+
exports.USER_CONFIG = __assign({ SHELL: true }, _userConf);
|
|
23
34
|
exports.MOBILE_TEMPLATE_URL = "git@github.com:".concat(exports.orgName, "/mobile-template.git");
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
var cleye_1 = require("cleye");
|
|
5
5
|
var configure_1 = require("./commands/configure");
|
|
6
6
|
var createApp_1 = require("./commands/createApp");
|
|
7
|
+
var downloadKeystores_1 = require("./commands/downloadKeystores");
|
|
7
8
|
var keystoresAndroid_1 = require("./commands/keystoresAndroid");
|
|
8
9
|
var rename_1 = require("./commands/rename");
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
11
|
var packageJson = require('../package.json');
|
|
11
12
|
(0, cleye_1.cli)({
|
|
12
13
|
name: 'codeleap',
|
|
13
|
-
commands: [
|
|
14
|
+
commands: [
|
|
15
|
+
keystoresAndroid_1.generateReleaseKey,
|
|
16
|
+
rename_1.renameMobileCommand,
|
|
17
|
+
createApp_1.createAppCommand,
|
|
18
|
+
configure_1.configureCommand,
|
|
19
|
+
downloadKeystores_1.downloadKeystores
|
|
20
|
+
],
|
|
14
21
|
version: packageJson.version,
|
|
15
22
|
});
|
|
@@ -1,7 +1,49 @@
|
|
|
1
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
2
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AndroidConfigFile = void 0;
|
|
42
|
+
exports.generateReleaseKeystore = exports.AndroidConfigFile = void 0;
|
|
4
43
|
var utils_1 = require("../utils");
|
|
44
|
+
var lib_1 = require("../../lib");
|
|
45
|
+
var generate_password_1 = __importDefault(require("generate-password"));
|
|
46
|
+
var constants_1 = require("../../constants");
|
|
5
47
|
var AndroidConfigFile = /** @class */ (function () {
|
|
6
48
|
function AndroidConfigFile(path) {
|
|
7
49
|
this.path = path;
|
|
@@ -25,3 +67,82 @@ var AndroidConfigFile = /** @class */ (function () {
|
|
|
25
67
|
return AndroidConfigFile;
|
|
26
68
|
}());
|
|
27
69
|
exports.AndroidConfigFile = AndroidConfigFile;
|
|
70
|
+
function genKeystore(type, _cwd) {
|
|
71
|
+
if (_cwd === void 0) { _cwd = constants_1.cwd; }
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var pass, alias, fileName;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
pass = generate_password_1.default.generate({
|
|
78
|
+
length: 26,
|
|
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
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
var generateReleaseKeystore = function (androidFolder) { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
+
var keystoresDir, releaseCredentials, configFile, log;
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0:
|
|
129
|
+
keystoresDir = lib_1.path.join(androidFolder || constants_1.cwd, 'app', 'keystores');
|
|
130
|
+
if (utils_1.fs.existsSync(lib_1.path.join(keystoresDir, 'release.keystore'))) {
|
|
131
|
+
return [2 /*return*/];
|
|
132
|
+
}
|
|
133
|
+
return [4 /*yield*/, genKeystore('release', keystoresDir)];
|
|
134
|
+
case 1:
|
|
135
|
+
releaseCredentials = _a.sent();
|
|
136
|
+
configFile = new AndroidConfigFile(lib_1.path.join(keystoresDir, 'config.json'));
|
|
137
|
+
configFile.setKey(releaseCredentials.keyname, releaseCredentials);
|
|
138
|
+
log = [
|
|
139
|
+
"Generated ".concat(releaseCredentials.keyname, " at ").concat(keystoresDir, "."),
|
|
140
|
+
"Upload this file as a document to 1Password, and add the following to it's \"notes\" section",
|
|
141
|
+
JSON.stringify(configFile.data, null, 1),
|
|
142
|
+
].join('\n');
|
|
143
|
+
console.log(log);
|
|
144
|
+
return [2 /*return*/];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}); };
|
|
148
|
+
exports.generateReleaseKeystore = generateReleaseKeystore;
|
|
@@ -93,19 +93,18 @@ var utils_2 = require("./utils");
|
|
|
93
93
|
var path_1 = __importDefault(require("path"));
|
|
94
94
|
var fs_1 = __importDefault(require("fs"));
|
|
95
95
|
var walk_1 = require("../walk");
|
|
96
|
-
var firebase_admin_1 = __importDefault(require("firebase-admin"));
|
|
97
96
|
var node_keytool_1 = __importDefault(require("node-keytool"));
|
|
98
|
-
var
|
|
99
|
-
var firebase_1 = require("../firebase");
|
|
97
|
+
var keystore_1 = require("./keystore");
|
|
100
98
|
function renameAndroid(androidFolder, newName, options) {
|
|
101
99
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var newBundleName, androidManifest, stringsXml, bundleId, currentName, pm, androidAppReqs, androidApps, googleServiceFile, newApp_1, newGoogleServicesFile, keystoresFolder, keystores, keystores_1, keystores_1_1, keystore, keyPathData, valid, storeTypeMap,
|
|
103
|
-
var e_1,
|
|
100
|
+
var newBundleName, _a, firebase, androidManifest, stringsXml, bundleId, currentName, pm, androidAppReqs, androidApps, googleServiceFile, newApp_1, newGoogleServicesFile, keystoresFolder, keystores, gradleProperties, keystores_1, keystores_1_1, keystore, keyPathData, valid, storeTypeMap, key;
|
|
101
|
+
var e_1, _b;
|
|
104
102
|
var _this = this;
|
|
105
|
-
return __generator(this, function (
|
|
106
|
-
switch (
|
|
103
|
+
return __generator(this, function (_c) {
|
|
104
|
+
switch (_c.label) {
|
|
107
105
|
case 0:
|
|
108
106
|
newBundleName = (0, utils_1.getNewBundleName)(newName);
|
|
107
|
+
_a = (options || {}).firebase, firebase = _a === void 0 ? null : _a;
|
|
109
108
|
androidManifest = fs_1.default.readFileSync(path_1.default.join(androidFolder, 'app', 'src', 'main', 'AndroidManifest.xml')).toString();
|
|
110
109
|
stringsXml = fs_1.default.readFileSync(path_1.default.join(androidFolder, 'app', 'src', 'main', 'res', 'values', 'strings.xml')).toString();
|
|
111
110
|
bundleId = (0, utils_2.getAndroidBundleId)(androidManifest);
|
|
@@ -191,13 +190,14 @@ function renameAndroid(androidFolder, newName, options) {
|
|
|
191
190
|
}
|
|
192
191
|
})];
|
|
193
192
|
case 1:
|
|
194
|
-
|
|
195
|
-
if (!
|
|
193
|
+
_c.sent();
|
|
194
|
+
if (!firebase)
|
|
196
195
|
return [2 /*return*/];
|
|
197
|
-
pm =
|
|
196
|
+
pm = firebase.projectManagement();
|
|
197
|
+
console.log(pm.app.options, pm.app.name);
|
|
198
198
|
return [4 /*yield*/, pm.listAndroidApps()];
|
|
199
199
|
case 2:
|
|
200
|
-
androidAppReqs = (
|
|
200
|
+
androidAppReqs = (_c.sent()).map(function (a) { return __awaiter(_this, void 0, void 0, function () {
|
|
201
201
|
var _a;
|
|
202
202
|
var _b;
|
|
203
203
|
return __generator(this, function (_c) {
|
|
@@ -210,18 +210,19 @@ function renameAndroid(androidFolder, newName, options) {
|
|
|
210
210
|
}
|
|
211
211
|
});
|
|
212
212
|
}); });
|
|
213
|
+
console.log(androidAppReqs);
|
|
213
214
|
return [4 /*yield*/, Promise.all(androidAppReqs)];
|
|
214
215
|
case 3:
|
|
215
|
-
androidApps =
|
|
216
|
+
androidApps = _c.sent();
|
|
216
217
|
googleServiceFile = path_1.default.join(androidFolder, 'app', 'google-services.json');
|
|
217
218
|
if (!!androidApps.some(function (a) { return a.meta.packageName === newBundleName; })) return [3 /*break*/, 6];
|
|
218
219
|
console.log("Creating new android app on firebase and updating google-services.json");
|
|
219
220
|
return [4 /*yield*/, pm.createAndroidApp(newBundleName, newName.trim())];
|
|
220
221
|
case 4:
|
|
221
|
-
newApp_1 =
|
|
222
|
+
newApp_1 = _c.sent();
|
|
222
223
|
return [4 /*yield*/, newApp_1.getConfig()];
|
|
223
224
|
case 5:
|
|
224
|
-
newGoogleServicesFile =
|
|
225
|
+
newGoogleServicesFile = _c.sent();
|
|
225
226
|
fs_1.default.writeFileSync(googleServiceFile, newGoogleServicesFile, {
|
|
226
227
|
encoding: 'utf-8',
|
|
227
228
|
});
|
|
@@ -229,10 +230,11 @@ function renameAndroid(androidFolder, newName, options) {
|
|
|
229
230
|
keystores = fs_1.default.readdirSync(keystoresFolder, {
|
|
230
231
|
withFileTypes: true,
|
|
231
232
|
});
|
|
233
|
+
gradleProperties = new keystore_1.AndroidConfigFile(path_1.default.join(androidFolder, 'app', 'keystores', 'config.json'));
|
|
232
234
|
try {
|
|
233
235
|
for (keystores_1 = __values(keystores), keystores_1_1 = keystores_1.next(); !keystores_1_1.done; keystores_1_1 = keystores_1.next()) {
|
|
234
236
|
keystore = keystores_1_1.value;
|
|
235
|
-
keyPathData = (0,
|
|
237
|
+
keyPathData = (0, utils_1.parseFilePathData)(keystore.name);
|
|
236
238
|
valid = ['jks', 'keystore'].includes(keyPathData.extension) && keystore.isFile();
|
|
237
239
|
if (!valid) {
|
|
238
240
|
continue;
|
|
@@ -241,10 +243,9 @@ function renameAndroid(androidFolder, newName, options) {
|
|
|
241
243
|
'keystore': 'PKCS12',
|
|
242
244
|
'jks': 'JKS',
|
|
243
245
|
};
|
|
244
|
-
|
|
245
|
-
key = (0, node_keytool_1.default)(path_1.default.join(keystoresFolder, keystore.name), gradleProperties["".concat(keyPathData.name.toUpperCase(), "_KEY_PASSWORD")], { debug: false, storeType: storeTypeMap[keyPathData.extension] });
|
|
246
|
+
key = (0, node_keytool_1.default)(path_1.default.join(keystoresFolder, keystore.name), gradleProperties[keystore.name].storePassword, { debug: false, storeType: storeTypeMap[keyPathData.extension] });
|
|
246
247
|
key.list(function (err, vals) {
|
|
247
|
-
vals.certs.forEach(function (c) {
|
|
248
|
+
return vals.certs.forEach(function (c) {
|
|
248
249
|
newApp_1.addShaCertificate({
|
|
249
250
|
certType: c.algorithm.toLowerCase().replace('-', ''),
|
|
250
251
|
shaHash: c.fingerprint,
|
|
@@ -256,11 +257,11 @@ function renameAndroid(androidFolder, newName, options) {
|
|
|
256
257
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
257
258
|
finally {
|
|
258
259
|
try {
|
|
259
|
-
if (keystores_1_1 && !keystores_1_1.done && (
|
|
260
|
+
if (keystores_1_1 && !keystores_1_1.done && (_b = keystores_1.return)) _b.call(keystores_1);
|
|
260
261
|
}
|
|
261
262
|
finally { if (e_1) throw e_1.error; }
|
|
262
263
|
}
|
|
263
|
-
|
|
264
|
+
_c.label = 6;
|
|
264
265
|
case 6: return [2 /*return*/];
|
|
265
266
|
}
|
|
266
267
|
});
|
|
@@ -42,7 +42,7 @@ function initRepoFromTemplate(templateUrl, location) {
|
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
43
|
return __generator(this, function (_a) {
|
|
44
44
|
switch (_a.label) {
|
|
45
|
-
case 0: return [4 /*yield*/, __1.git.clone
|
|
45
|
+
case 0: return [4 /*yield*/, __1.git.raw('clone', templateUrl, location)];
|
|
46
46
|
case 1:
|
|
47
47
|
_a.sent();
|
|
48
48
|
__1.fs.rmSync(__1.path.join(location, '.git'), { force: true, recursive: true });
|
|
@@ -35,33 +35,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e) throw e.error; }
|
|
62
|
-
}
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
66
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
67
40
|
};
|
|
@@ -72,14 +45,13 @@ var path_1 = __importDefault(require("path"));
|
|
|
72
45
|
var common_1 = require("./common");
|
|
73
46
|
var __1 = require("..");
|
|
74
47
|
var spinner_1 = require("../spinner");
|
|
75
|
-
var
|
|
48
|
+
var keystore_1 = require("../android/keystore");
|
|
49
|
+
var firebase_1 = require("../firebase");
|
|
76
50
|
function createMobileApp(params) {
|
|
77
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
-
var name, _a, client, _b, location, repoName, repoUrl,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return __generator(this, function (_g) {
|
|
82
|
-
switch (_g.label) {
|
|
52
|
+
var name, _a, client, _b, location, repoName, repoUrl, firebase, androidFolder;
|
|
53
|
+
return __generator(this, function (_c) {
|
|
54
|
+
switch (_c.label) {
|
|
83
55
|
case 0:
|
|
84
56
|
name = params.name, _a = params.client, client = _a === void 0 ? true : _a;
|
|
85
57
|
_b = params.location, location = _b === void 0 ? null : _b;
|
|
@@ -91,130 +63,132 @@ function createMobileApp(params) {
|
|
|
91
63
|
name: "Creating local repository at ".concat(location),
|
|
92
64
|
})];
|
|
93
65
|
case 1:
|
|
94
|
-
|
|
66
|
+
_c.sent();
|
|
95
67
|
return [4 /*yield*/, __1.git.cwd({
|
|
96
68
|
path: location,
|
|
97
69
|
})];
|
|
98
70
|
case 2:
|
|
99
|
-
|
|
71
|
+
_c.sent();
|
|
100
72
|
repoUrl = '';
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
name:
|
|
73
|
+
// await spinWhileNotCompleted(
|
|
74
|
+
// async () => {
|
|
75
|
+
// try {
|
|
76
|
+
// const response = await octokit.request('POST /orgs/{org}/repos', {
|
|
77
|
+
// org: orgName,
|
|
78
|
+
// name: repoName,
|
|
79
|
+
// description: `${name} mobile app`,
|
|
80
|
+
// 'private': true,
|
|
81
|
+
// })
|
|
82
|
+
// repoUrl = response.data.ssh_url
|
|
83
|
+
// } catch (e) {
|
|
84
|
+
// console.log(`Repository ${repoName} already exists, skipping creation...`)
|
|
85
|
+
// } repoUrl = `git@github.com:${orgName}/${repoName}.git`
|
|
86
|
+
// },
|
|
87
|
+
// {
|
|
88
|
+
// name: `Creating remote repository ${repoName}`,
|
|
89
|
+
// },
|
|
90
|
+
// )
|
|
91
|
+
// await spinWhileNotCompleted(
|
|
92
|
+
// () => git.raw('-C', location, 'remote', 'add', 'origin', repoUrl),
|
|
93
|
+
// {
|
|
94
|
+
// name: 'Adding repo remote url',
|
|
95
|
+
// },
|
|
96
|
+
// )
|
|
97
|
+
return [4 /*yield*/, __1.inquirer.prompt({
|
|
98
|
+
type: 'confirm',
|
|
99
|
+
name: 'wait',
|
|
100
|
+
message: 'To initialize firebase, do the following:' + (0, __1.listPrompt)([
|
|
101
|
+
'Create a firebase project.',
|
|
102
|
+
'Replace the content of firebase_admin.json with the credentials from your project.'
|
|
103
|
+
], true) + 'For detailed instructions, see http://docs.codeleap.co.uk/mobile/starting-a-project.\n Make sure to change the file before proceeding.'
|
|
128
104
|
})];
|
|
129
105
|
case 3:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
106
|
+
// await spinWhileNotCompleted(
|
|
107
|
+
// async () => {
|
|
108
|
+
// try {
|
|
109
|
+
// const response = await octokit.request('POST /orgs/{org}/repos', {
|
|
110
|
+
// org: orgName,
|
|
111
|
+
// name: repoName,
|
|
112
|
+
// description: `${name} mobile app`,
|
|
113
|
+
// 'private': true,
|
|
114
|
+
// })
|
|
115
|
+
// repoUrl = response.data.ssh_url
|
|
116
|
+
// } catch (e) {
|
|
117
|
+
// console.log(`Repository ${repoName} already exists, skipping creation...`)
|
|
118
|
+
// } repoUrl = `git@github.com:${orgName}/${repoName}.git`
|
|
119
|
+
// },
|
|
120
|
+
// {
|
|
121
|
+
// name: `Creating remote repository ${repoName}`,
|
|
122
|
+
// },
|
|
123
|
+
// )
|
|
124
|
+
// await spinWhileNotCompleted(
|
|
125
|
+
// () => git.raw('-C', location, 'remote', 'add', 'origin', repoUrl),
|
|
126
|
+
// {
|
|
127
|
+
// name: 'Adding repo remote url',
|
|
128
|
+
// },
|
|
129
|
+
// )
|
|
130
|
+
_c.sent();
|
|
131
|
+
return [4 /*yield*/, (0, firebase_1.loadFirebaseAdmin)(path_1.default.join(location, 'firebase_admin.json'))];
|
|
134
132
|
case 4:
|
|
135
|
-
|
|
133
|
+
firebase = _c.sent();
|
|
136
134
|
androidFolder = path_1.default.join(location, 'android');
|
|
137
|
-
return [4 /*yield*/, (0, spinner_1.spinWhileNotCompleted)(function () { return (0,
|
|
138
|
-
|
|
139
|
-
}); }, {
|
|
140
|
-
name: 'Renaming android app',
|
|
135
|
+
return [4 /*yield*/, (0, spinner_1.spinWhileNotCompleted)(function () { return (0, keystore_1.generateReleaseKeystore)(androidFolder); }, {
|
|
136
|
+
name: 'Generating release.keystore'
|
|
141
137
|
})];
|
|
142
138
|
case 5:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return [4 /*yield*/, (0, spinner_1.spinWhileNotCompleted)(function () { return (0, __1.renameIos)(iosFolder, name, {
|
|
139
|
+
_c.sent();
|
|
140
|
+
return [4 /*yield*/, (0, spinner_1.spinWhileNotCompleted)(function () { return (0, __1.renameAndroid)(androidFolder, name, {
|
|
146
141
|
changeBundle: true,
|
|
142
|
+
firebase: firebase
|
|
147
143
|
}); }, {
|
|
148
|
-
name: 'Renaming
|
|
149
|
-
})
|
|
144
|
+
name: 'Renaming android app',
|
|
145
|
+
})
|
|
146
|
+
// const iosFolder = path.join(location, 'ios')
|
|
147
|
+
// await spinWhileNotCompleted(
|
|
148
|
+
// () => renameIos(iosFolder, name, {
|
|
149
|
+
// changeBundle: true,
|
|
150
|
+
// firebase
|
|
151
|
+
// }),
|
|
152
|
+
// {
|
|
153
|
+
// name: 'Renaming ios app',
|
|
154
|
+
// },
|
|
155
|
+
// )
|
|
156
|
+
// await spinWhileNotCompleted(
|
|
157
|
+
// async () => {
|
|
158
|
+
// await git.raw('-C', location, 'add', '.')
|
|
159
|
+
// await git.raw('-C', location, 'commit', '-m', 'Initialize project')
|
|
160
|
+
// await git.raw('-C', location, 'push', 'origin', 'master')
|
|
161
|
+
// },
|
|
162
|
+
// {
|
|
163
|
+
// name: 'Pushing changes to repository',
|
|
164
|
+
// },
|
|
165
|
+
// )
|
|
166
|
+
// const secrets = {
|
|
167
|
+
// 'GH_PAT': USER_CONFIG.GITHUB_TOKEN,
|
|
168
|
+
// 'REPOSITORY_BRANCH': name,
|
|
169
|
+
// }
|
|
170
|
+
// const pubKey = await octokit.request('GET /repos/{owner}/{repo}/actions/secrets/public-key', {
|
|
171
|
+
// owner: orgName,
|
|
172
|
+
// repo: repoName,
|
|
173
|
+
// })
|
|
174
|
+
// const repoPublicKey = Buffer.from(pubKey.data.key, 'base64')
|
|
175
|
+
// for (const [key, value] of Object.entries(secrets)) {
|
|
176
|
+
// const valBuffer = Buffer.from(value)
|
|
177
|
+
// const encriptedVal = Buffer.from(
|
|
178
|
+
// crypto_box_seal(valBuffer, repoPublicKey),
|
|
179
|
+
// ).toString('base64')
|
|
180
|
+
// await octokit.rest.actions.createOrUpdateRepoSecret({
|
|
181
|
+
// owner: orgName,
|
|
182
|
+
// repo: repoName,
|
|
183
|
+
// secret_name: key,
|
|
184
|
+
// encrypted_value: encriptedVal,
|
|
185
|
+
// key_id: pubKey.data.key_id,
|
|
186
|
+
// })
|
|
187
|
+
// }
|
|
188
|
+
];
|
|
150
189
|
case 6:
|
|
151
|
-
|
|
152
|
-
return [
|
|
153
|
-
return __generator(this, function (_a) {
|
|
154
|
-
switch (_a.label) {
|
|
155
|
-
case 0: return [4 /*yield*/, __1.git.raw('-C', location, 'add', '.')];
|
|
156
|
-
case 1:
|
|
157
|
-
_a.sent();
|
|
158
|
-
return [4 /*yield*/, __1.git.raw('-C', location, 'commit', '-m', 'Initialize project')];
|
|
159
|
-
case 2:
|
|
160
|
-
_a.sent();
|
|
161
|
-
return [4 /*yield*/, __1.git.raw('-C', location, 'push', 'origin', 'master')];
|
|
162
|
-
case 3:
|
|
163
|
-
_a.sent();
|
|
164
|
-
return [2 /*return*/];
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}); }, {
|
|
168
|
-
name: 'Pushing changes to repository',
|
|
169
|
-
})];
|
|
170
|
-
case 7:
|
|
171
|
-
_g.sent();
|
|
172
|
-
secrets = {
|
|
173
|
-
'GH_PAT': constants_1.USER_CONFIG.GITHUB_TOKEN,
|
|
174
|
-
'REPOSITORY_BRANCH': name,
|
|
175
|
-
};
|
|
176
|
-
return [4 /*yield*/, __1.octokit.request('GET /repos/{owner}/{repo}/actions/secrets/public-key', {
|
|
177
|
-
owner: constants_1.orgName,
|
|
178
|
-
repo: repoName,
|
|
179
|
-
})];
|
|
180
|
-
case 8:
|
|
181
|
-
pubKey = _g.sent();
|
|
182
|
-
repoPublicKey = Buffer.from(pubKey.data.key, 'base64');
|
|
183
|
-
_g.label = 9;
|
|
184
|
-
case 9:
|
|
185
|
-
_g.trys.push([9, 14, 15, 16]);
|
|
186
|
-
_c = __values(Object.entries(secrets)), _d = _c.next();
|
|
187
|
-
_g.label = 10;
|
|
188
|
-
case 10:
|
|
189
|
-
if (!!_d.done) return [3 /*break*/, 13];
|
|
190
|
-
_e = __read(_d.value, 2), key = _e[0], value = _e[1];
|
|
191
|
-
valBuffer = Buffer.from(value);
|
|
192
|
-
encriptedVal = Buffer.from((0, libsodium_wrappers_1.crypto_box_seal)(valBuffer, repoPublicKey)).toString('base64');
|
|
193
|
-
return [4 /*yield*/, __1.octokit.rest.actions.createOrUpdateRepoSecret({
|
|
194
|
-
owner: constants_1.orgName,
|
|
195
|
-
repo: repoName,
|
|
196
|
-
secret_name: key,
|
|
197
|
-
encrypted_value: encriptedVal,
|
|
198
|
-
key_id: pubKey.data.key_id,
|
|
199
|
-
})];
|
|
200
|
-
case 11:
|
|
201
|
-
_g.sent();
|
|
202
|
-
_g.label = 12;
|
|
203
|
-
case 12:
|
|
204
|
-
_d = _c.next();
|
|
205
|
-
return [3 /*break*/, 10];
|
|
206
|
-
case 13: return [3 /*break*/, 16];
|
|
207
|
-
case 14:
|
|
208
|
-
e_1_1 = _g.sent();
|
|
209
|
-
e_1 = { error: e_1_1 };
|
|
210
|
-
return [3 /*break*/, 16];
|
|
211
|
-
case 15:
|
|
212
|
-
try {
|
|
213
|
-
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
214
|
-
}
|
|
215
|
-
finally { if (e_1) throw e_1.error; }
|
|
216
|
-
return [7 /*endfinally*/];
|
|
217
|
-
case 16: return [2 /*return*/];
|
|
190
|
+
_c.sent();
|
|
191
|
+
return [2 /*return*/];
|
|
218
192
|
}
|
|
219
193
|
});
|
|
220
194
|
});
|
package/dist/lib/firebase.js
CHANGED
|
@@ -39,29 +39,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.
|
|
42
|
+
exports.loadFirebaseAdmin = void 0;
|
|
43
43
|
var firebase_admin_1 = __importDefault(require("firebase-admin"));
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
44
|
+
// let _firebaseApp:firebase.app.App = null
|
|
45
|
+
// if (!_firebaseApp) {
|
|
46
|
+
// try {
|
|
47
|
+
// _firebaseApp = firebase.initializeApp({
|
|
48
|
+
// credential: firebase.credential.cert(
|
|
49
|
+
// path.join(cwd, 'firebase_admin.json'),
|
|
50
|
+
// ),
|
|
51
|
+
// })
|
|
52
|
+
// } catch (e) {
|
|
53
|
+
// }
|
|
54
|
+
// }
|
|
56
55
|
function loadFirebaseAdmin(credentialPath) {
|
|
57
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
58
57
|
return __generator(this, function (_a) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return [2 /*return*/];
|
|
58
|
+
return [2 /*return*/, firebase_admin_1.default.initializeApp({
|
|
59
|
+
credential: firebase_admin_1.default.credential.cert(credentialPath),
|
|
60
|
+
})];
|
|
63
61
|
});
|
|
64
62
|
});
|
|
65
63
|
}
|
|
66
64
|
exports.loadFirebaseAdmin = loadFirebaseAdmin;
|
|
67
|
-
|
|
65
|
+
// export const firebaseApp = _firebaseApp
|
package/dist/lib/index.js
CHANGED
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "inquirer", { enumerable: true, get: function ()
|
|
|
27
27
|
var octokit_1 = require("octokit");
|
|
28
28
|
var simple_git_1 = __importDefault(require("simple-git"));
|
|
29
29
|
var constants_1 = require("../constants");
|
|
30
|
+
console.log(constants_1.cwd);
|
|
30
31
|
exports.git = (0, simple_git_1.default)({
|
|
31
32
|
baseDir: constants_1.cwd,
|
|
32
33
|
});
|
package/dist/lib/ios/rename.js
CHANGED
|
@@ -56,15 +56,14 @@ var utils_2 = require("./utils");
|
|
|
56
56
|
var path_1 = __importDefault(require("path"));
|
|
57
57
|
var fs_1 = __importDefault(require("fs"));
|
|
58
58
|
var walk_1 = require("../walk");
|
|
59
|
-
var firebase_admin_1 = __importDefault(require("firebase-admin"));
|
|
60
|
-
var firebase_1 = require("../firebase");
|
|
61
59
|
function renameIos(iosFolder, newName, options) {
|
|
62
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var newBundleName, pbxProjPath, pbxProj, bundleId, currentName, renameQueue, pm, iosAppReqs, iosApps, googleServiceFile, newApp, newPlistFile;
|
|
61
|
+
var firebase, newBundleName, pbxProjPath, pbxProj, bundleId, currentName, renameQueue, pm, iosAppReqs, iosApps, googleServiceFile, newApp, newPlistFile;
|
|
64
62
|
var _this = this;
|
|
65
63
|
return __generator(this, function (_a) {
|
|
66
64
|
switch (_a.label) {
|
|
67
65
|
case 0:
|
|
66
|
+
firebase = (options || {}).firebase;
|
|
68
67
|
newBundleName = (0, utils_1.getNewBundleName)(newName);
|
|
69
68
|
pbxProjPath = path_1.default.join(iosFolder, fs_1.default.readdirSync(iosFolder).find(function (x) { return x.endsWith('.xcodeproj'); }), 'project.pbxproj');
|
|
70
69
|
pbxProj = fs_1.default.readFileSync(pbxProjPath).toString();
|
|
@@ -121,9 +120,9 @@ function renameIos(iosFolder, newName, options) {
|
|
|
121
120
|
renameQueue.forEach(function (i) {
|
|
122
121
|
fs_1.default.renameSync(i.from, i.to);
|
|
123
122
|
});
|
|
124
|
-
if (!
|
|
123
|
+
if (!firebase)
|
|
125
124
|
return [2 /*return*/];
|
|
126
|
-
pm =
|
|
125
|
+
pm = firebase.projectManagement();
|
|
127
126
|
return [4 /*yield*/, pm.listIosApps()];
|
|
128
127
|
case 2:
|
|
129
128
|
iosAppReqs = (_a.sent()).map(function (a) { return __awaiter(_this, void 0, void 0, function () {
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
4
|
};
|
|
30
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.path = exports.fs = exports.subprocess = exports.getNewBundleName = void 0;
|
|
6
|
+
exports.parseFilePathData = exports.findExecutable = exports.path = exports.fs = exports.listPrompt = exports.subprocess = exports.getNewBundleName = void 0;
|
|
32
7
|
var child_process_1 = __importDefault(require("child_process"));
|
|
33
8
|
var getNewBundleName = function (newName) { return "uk.co.codeleap.".concat(newName.trim()); };
|
|
34
9
|
exports.getNewBundleName = getNewBundleName;
|
|
@@ -40,7 +15,7 @@ function subprocess(name) {
|
|
|
40
15
|
return new Promise(function (resolve, reject) {
|
|
41
16
|
var _a, _b, _c, _d;
|
|
42
17
|
console.log("Running ".concat(params[0], " ").concat(params[1].join(' ')));
|
|
43
|
-
var child = child_process_1.default.spawn
|
|
18
|
+
var child = child_process_1.default.spawn(params[0], params[1].map(function (x) { return JSON.stringify(x); }), params[2]);
|
|
44
19
|
child.on('error', function (err) {
|
|
45
20
|
console.log("".concat(name, " finished with error: "), err.toString());
|
|
46
21
|
reject(err);
|
|
@@ -63,7 +38,41 @@ function subprocess(name) {
|
|
|
63
38
|
});
|
|
64
39
|
}
|
|
65
40
|
exports.subprocess = subprocess;
|
|
41
|
+
function listPrompt(items, numbered) {
|
|
42
|
+
if (numbered === void 0) { numbered = false; }
|
|
43
|
+
var textArr = items.map(function (i, idx) {
|
|
44
|
+
var prefix = numbered ? "".concat(idx + 1, ". ") : '- ';
|
|
45
|
+
return "".concat(prefix).concat(i);
|
|
46
|
+
});
|
|
47
|
+
return "\n".concat(textArr.join('\n'), "\n");
|
|
48
|
+
}
|
|
49
|
+
exports.listPrompt = listPrompt;
|
|
66
50
|
var path_1 = __importDefault(require("path"));
|
|
67
51
|
exports.path = path_1.default;
|
|
68
52
|
var fs_1 = __importDefault(require("fs"));
|
|
69
53
|
exports.fs = fs_1.default;
|
|
54
|
+
var os_1 = __importDefault(require("os"));
|
|
55
|
+
function findExecutable(exec) {
|
|
56
|
+
if (os_1.default.platform() === 'win32')
|
|
57
|
+
return;
|
|
58
|
+
return child_process_1.default.execSync('which ' + exec).toString().replace(/\n/g, '');
|
|
59
|
+
}
|
|
60
|
+
exports.findExecutable = findExecutable;
|
|
61
|
+
var separators = /[\\\/]+/;
|
|
62
|
+
function parseFilePathData(path) {
|
|
63
|
+
var parts = path.split(separators);
|
|
64
|
+
var lastPart = parts[parts.length - 1];
|
|
65
|
+
var fileName = lastPart;
|
|
66
|
+
var ext = '';
|
|
67
|
+
if (lastPart.includes('.')) {
|
|
68
|
+
var dotIdx = fileName.lastIndexOf('.');
|
|
69
|
+
fileName = fileName.substring(0, dotIdx);
|
|
70
|
+
ext = lastPart.substring(dotIdx + 1);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
path: parts.slice(0, -1).join('/'),
|
|
74
|
+
extension: ext,
|
|
75
|
+
name: fileName,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
exports.parseFilePathData = parseFilePathData;
|
package/dist/lib/walk.js
CHANGED
|
@@ -51,9 +51,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.walkDir = void 0;
|
|
54
|
-
var common_1 = require("@codeleap/common");
|
|
55
54
|
var fs_1 = __importDefault(require("fs"));
|
|
56
55
|
var dive_1 = __importDefault(require("dive"));
|
|
56
|
+
var utils_1 = require("./utils");
|
|
57
57
|
var matchFile = function (path, stat, config) {
|
|
58
58
|
var isDir = stat.isDirectory();
|
|
59
59
|
if (isDir && !config.dir) {
|
|
@@ -62,7 +62,7 @@ var matchFile = function (path, stat, config) {
|
|
|
62
62
|
if (!isDir && !config.file) {
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
|
-
var pathData = (0,
|
|
65
|
+
var pathData = (0, utils_1.parseFilePathData)(path);
|
|
66
66
|
var conditions = [];
|
|
67
67
|
if (!!config.name) {
|
|
68
68
|
var nameMatch = false;
|
|
@@ -70,7 +70,7 @@ var matchFile = function (path, stat, config) {
|
|
|
70
70
|
nameMatch = config.name.test(path);
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
|
-
var matchConfig = (0,
|
|
73
|
+
var matchConfig = (0, utils_1.parseFilePathData)(config.name);
|
|
74
74
|
nameMatch = [
|
|
75
75
|
pathData.name === matchConfig.name,
|
|
76
76
|
pathData.extension === matchConfig.extension,
|
|
@@ -94,7 +94,7 @@ function walkDir(config) {
|
|
|
94
94
|
return [2 /*return*/, new Promise(function (resolve) {
|
|
95
95
|
(0, dive_1.default)(config.path, options, function (err, file, stat) {
|
|
96
96
|
var isDir = stat.isDirectory();
|
|
97
|
-
var pathData = (0,
|
|
97
|
+
var pathData = (0, utils_1.parseFilePathData)(file);
|
|
98
98
|
if (options.ignore) {
|
|
99
99
|
var ignore = options.ignore.some(function (i) { return matchFile(file, stat, i); });
|
|
100
100
|
if (ignore)
|
|
@@ -117,7 +117,7 @@ function walkDir(config) {
|
|
|
117
117
|
parentPath: pathData.path,
|
|
118
118
|
file: fileInfo,
|
|
119
119
|
});
|
|
120
|
-
if (!
|
|
120
|
+
if (![undefined, null].includes(newContent) && !isDir) {
|
|
121
121
|
fs_1.default.writeFileSync(file, newContent);
|
|
122
122
|
}
|
|
123
123
|
}, function () {
|