rnbuilder 0.5.22 → 0.5.24

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 CHANGED
@@ -20,7 +20,7 @@ $ npm install -g rnbuilder
20
20
  $ rnbuilder COMMAND
21
21
  running command...
22
22
  $ rnbuilder (-v|--version|version)
23
- rnbuilder/0.5.22 darwin-arm64 node-v14.21.1
23
+ rnbuilder/0.5.24 darwin-arm64 node-v16.19.0
24
24
  $ rnbuilder --help [COMMAND]
25
25
  USAGE
26
26
  $ rnbuilder COMMAND
@@ -34,6 +34,7 @@ USAGE
34
34
  * [`rnbuilder help [COMMAND]`](#rnbuilder-help-command)
35
35
  * [`rnbuilder initialize`](#rnbuilder-initialize)
36
36
  * [`rnbuilder match-nuke [BUILD]`](#rnbuilder-match-nuke-build)
37
+ * [`rnbuilder setup [SETUP]`](#rnbuilder-setup-setup)
37
38
  * [`rnbuilder sync-udids [BUILD]`](#rnbuilder-sync-udids-build)
38
39
 
39
40
  ## `rnbuilder build [BUILD]`
@@ -58,7 +59,7 @@ EXAMPLE
58
59
  hello world from ./src/build.ts!
59
60
  ```
60
61
 
61
- _See code: [src/commands/build.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.22/src/commands/build.ts)_
62
+ _See code: [src/commands/build.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.24/src/commands/build.ts)_
62
63
 
63
64
  ## `rnbuilder codepush [BUILD]`
64
65
 
@@ -77,7 +78,7 @@ EXAMPLE
77
78
  Push changes to existing apps ./src/firebase-sync-udids.ts!
78
79
  ```
79
80
 
80
- _See code: [src/commands/codepush.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.22/src/commands/codepush.ts)_
81
+ _See code: [src/commands/codepush.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.24/src/commands/codepush.ts)_
81
82
 
82
83
  ## `rnbuilder help [COMMAND]`
83
84
 
@@ -109,7 +110,7 @@ EXAMPLE
109
110
  initialize environment for first run from ./src/initialize.ts!
110
111
  ```
111
112
 
112
- _See code: [src/commands/initialize.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.22/src/commands/initialize.ts)_
113
+ _See code: [src/commands/initialize.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.24/src/commands/initialize.ts)_
113
114
 
114
115
  ## `rnbuilder match-nuke [BUILD]`
115
116
 
@@ -128,7 +129,25 @@ EXAMPLE
128
129
  Nuke certificates ./src/match-nuke.ts!
129
130
  ```
130
131
 
131
- _See code: [src/commands/match-nuke.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.22/src/commands/match-nuke.ts)_
132
+ _See code: [src/commands/match-nuke.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.24/src/commands/match-nuke.ts)_
133
+
134
+ ## `rnbuilder setup [SETUP]`
135
+
136
+ Setup new client
137
+
138
+ ```
139
+ USAGE
140
+ $ rnbuilder setup [SETUP]
141
+
142
+ OPTIONS
143
+ -h, --help show CLI help
144
+
145
+ EXAMPLE
146
+ $ rnbuilder build
147
+ hello world from ./src/setup.ts!
148
+ ```
149
+
150
+ _See code: [src/commands/setup.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.24/src/commands/setup.ts)_
132
151
 
133
152
  ## `rnbuilder sync-udids [BUILD]`
134
153
 
@@ -147,5 +166,5 @@ EXAMPLE
147
166
  Sync device UDIDs from firebase from ./src/firebase-sync-udids.ts!
148
167
  ```
149
168
 
150
- _See code: [src/commands/sync-udids.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.22/src/commands/sync-udids.ts)_
169
+ _See code: [src/commands/sync-udids.ts](https://github.com/r0b0t3d/rnbuilder/blob/v0.5.24/src/commands/sync-udids.ts)_
151
170
  <!-- commandsstop -->
@@ -6,7 +6,7 @@ const tslib_1 = require("tslib");
6
6
  const command_1 = require("@oclif/command");
7
7
  const inquirer = require("inquirer");
8
8
  const shell = require("shelljs");
9
- const utils_1 = require("../utils");
9
+ const common_1 = require("../utils/common");
10
10
  inquirer.registerPrompt('checkbox-plus', require('inquirer-checkbox-plus-prompt'));
11
11
  class Build extends command_1.Command {
12
12
  constructor() {
@@ -14,7 +14,7 @@ class Build extends command_1.Command {
14
14
  this.askForMissingFields = async (flags) => {
15
15
  let questions = [];
16
16
  if (!flags.client) {
17
- const clients = utils_1.getDirectories('./fastlane/clients');
17
+ const clients = common_1.getDirectories('./fastlane/clients');
18
18
  if (clients.length > 0) {
19
19
  questions.push({
20
20
  type: 'checkbox-plus',
@@ -23,7 +23,7 @@ class Build extends command_1.Command {
23
23
  pageSize: 100,
24
24
  highlight: true,
25
25
  searchable: true,
26
- default: ['yellow', 'red'],
26
+ default: [],
27
27
  source: (answersSoFar, input) => {
28
28
  input = input || '';
29
29
  return new Promise(resolve => {
@@ -31,6 +31,16 @@ class Build extends command_1.Command {
31
31
  resolve(result);
32
32
  });
33
33
  },
34
+ validate: (input) => {
35
+ return new Promise(resolve => {
36
+ if (input.length === 0) {
37
+ resolve('You need to select at least 1 client');
38
+ }
39
+ else {
40
+ resolve(true);
41
+ }
42
+ });
43
+ },
34
44
  });
35
45
  }
36
46
  }
@@ -123,33 +133,42 @@ class Build extends command_1.Command {
123
133
  result = Object.assign(Object.assign({}, result), answers);
124
134
  }
125
135
  if (result.installr || result.firebase) {
126
- const testersAnswer = await inquirer.prompt([{
136
+ const testersAnswer = await inquirer.prompt([
137
+ {
127
138
  type: 'expand',
128
139
  name: 'testers',
129
140
  message: 'Add testers to download the app?',
130
- choices: [{
141
+ choices: [
142
+ {
131
143
  key: 'g',
132
144
  name: 'Test groups',
133
145
  value: 'groups',
134
- }, {
146
+ },
147
+ {
135
148
  key: 't',
136
149
  name: 'Tester emails',
137
150
  value: 'testers',
138
- }, {
151
+ },
152
+ {
139
153
  key: 'n',
140
154
  name: 'No',
141
155
  value: 'no-tester',
142
- }],
156
+ },
157
+ ],
143
158
  default: 'no-tester',
144
- }]);
159
+ },
160
+ ]);
145
161
  if (testersAnswer.testers) {
146
162
  if (testersAnswer.testers !== 'no-tester') {
147
- const answers = await inquirer.prompt([{
163
+ const answers = await inquirer.prompt([
164
+ {
148
165
  type: 'input',
149
166
  name: 'testers',
150
- message: 'Please enter tester ' + (testersAnswer.testers === 'groups' ? 'group(s)' : 'email(s)'),
167
+ message: 'Please enter tester ' +
168
+ (testersAnswer.testers === 'groups' ? 'group(s)' : 'email(s)'),
151
169
  suffix: ' (separated by commas)',
152
- }]);
170
+ },
171
+ ]);
153
172
  result = Object.assign(Object.assign({}, result), { [testersAnswer.testers]: answers.testers });
154
173
  }
155
174
  }
@@ -177,7 +196,7 @@ class Build extends command_1.Command {
177
196
  const params = await this.askForMissingFields(flags);
178
197
  const { client, target } = params, otherParams = tslib_1.__rest(params, ["client", "target"]);
179
198
  const jsonFile = this.getJsonFile(otherParams.env);
180
- const parameters = utils_1.buildKeyValuePairs(Object.assign(Object.assign({}, otherParams), { json_file: jsonFile }));
199
+ const parameters = common_1.buildKeyValuePairs(Object.assign(Object.assign({}, otherParams), { json_file: jsonFile }));
181
200
  shell.exec(`git reset --hard && git checkout ${params.branch} && git pull`);
182
201
  shell.cd('fastlane');
183
202
  shell.exec('bundle update --bundler');
@@ -185,6 +204,7 @@ class Build extends command_1.Command {
185
204
  shell.exec('bundle update fastlane');
186
205
  shell.exec('bundle update cocoapods');
187
206
  shell.cd('../');
207
+ shell.exec('yarn install && npx pod-install');
188
208
  // Clean android if any
189
209
  if (target.includes('android')) {
190
210
  shell.cd('./android');
@@ -195,10 +215,7 @@ class Build extends command_1.Command {
195
215
  client.forEach((c) => {
196
216
  shell.cd(`fastlane/clients/${c}`);
197
217
  shell.exec('pwd');
198
- this.runPlatforms(target, [
199
- ...parameters,
200
- `client:${c}`,
201
- ], otherParams);
218
+ this.runPlatforms(target, [...parameters, `client:${c}`], otherParams);
202
219
  shell.cd('../../..');
203
220
  shell.exec('pwd');
204
221
  });
@@ -218,11 +235,31 @@ hello world from ./src/build.ts!
218
235
  ];
219
236
  Build.flags = {
220
237
  help: command_1.flags.help({ char: 'h' }),
221
- client: command_1.flags.string({ char: 'c', description: 'Set client that you want to build app' }),
222
- target: command_1.flags.string({ char: 't', description: 'Set the build target: android, ios or both', options: ['android', 'ios'] }),
223
- env: command_1.flags.string({ char: 'e', description: 'Set the environment: prod, adhoc, staging', options: ['staging', 'adhoc', 'prod'] }),
224
- branch: command_1.flags.string({ char: 'b', description: 'Set the source branch used to build the app' }),
225
- version: command_1.flags.string({ char: 'v', description: 'Set the version number for this build' }),
226
- installr: command_1.flags.string({ char: 'i', description: 'If enabled, the build will be uploaded to installR' }),
238
+ client: command_1.flags.string({
239
+ char: 'c',
240
+ description: 'Set client that you want to build app',
241
+ }),
242
+ target: command_1.flags.string({
243
+ char: 't',
244
+ description: 'Set the build target: android, ios or both',
245
+ options: ['android', 'ios'],
246
+ }),
247
+ env: command_1.flags.string({
248
+ char: 'e',
249
+ description: 'Set the environment: prod, adhoc, staging',
250
+ options: ['staging', 'adhoc', 'prod'],
251
+ }),
252
+ branch: command_1.flags.string({
253
+ char: 'b',
254
+ description: 'Set the source branch used to build the app',
255
+ }),
256
+ version: command_1.flags.string({
257
+ char: 'v',
258
+ description: 'Set the version number for this build',
259
+ }),
260
+ installr: command_1.flags.string({
261
+ char: 'i',
262
+ description: 'If enabled, the build will be uploaded to installR',
263
+ }),
227
264
  };
228
265
  Build.args = [{ name: 'build' }];
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const command_1 = require("@oclif/command");
5
5
  const shell = require("shelljs");
6
6
  const inquirer = require("inquirer");
7
- const utils_1 = require("../utils");
7
+ const common_1 = require("../utils/common");
8
8
  class CodePush extends command_1.Command {
9
9
  constructor() {
10
10
  super(...arguments);
11
11
  this.askForMissingFields = async (flags) => {
12
12
  const questions = [];
13
13
  if (!flags.client) {
14
- const clients = utils_1.getDirectories('./fastlane/clients');
14
+ const clients = common_1.getDirectories('./fastlane/clients');
15
15
  if (clients.length > 0) {
16
16
  questions.push({
17
17
  type: 'list',
@@ -58,9 +58,11 @@ class CodePush extends command_1.Command {
58
58
  if (client) {
59
59
  envPath += `/clients/${client}/fastlane`;
60
60
  }
61
- const appVersion = utils_1.getAppVersion(env, client, target);
61
+ const appVersion = common_1.getAppVersion(env, client, target);
62
62
  require('dotenv').config({ path: process.cwd() + '/' + envPath + '/.env' });
63
- const project = target === 'ios' ? process.env.CODE_PUSH_IOS_PROJECT : process.env.CODE_PUSH_ANDROID_PROJECT;
63
+ const project = target === 'ios'
64
+ ? process.env.CODE_PUSH_IOS_PROJECT
65
+ : process.env.CODE_PUSH_ANDROID_PROJECT;
64
66
  shell.exec(`appcenter codepush release-react -a ${project} -d ${env === 'staging' ? 'Staging' : 'Production'} --target-binary-version ${appVersion.version} --token ${process.env.CODE_PUSH_TOKEN}`);
65
67
  }
66
68
  }
@@ -73,6 +75,9 @@ CodePush.examples = [
73
75
  ];
74
76
  CodePush.flags = {
75
77
  help: command_1.flags.help({ char: 'h' }),
76
- client: command_1.flags.string({ char: 'c', description: 'Select client that you want to push update' }),
78
+ client: command_1.flags.string({
79
+ char: 'c',
80
+ description: 'Select client that you want to push update',
81
+ }),
77
82
  };
78
83
  CodePush.args = [{ name: 'build' }];
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const command_1 = require("@oclif/command");
5
5
  const shell = require("shelljs");
6
6
  const inquirer = require("inquirer");
7
- const utils_1 = require("../utils");
7
+ const common_1 = require("../utils/common");
8
8
  class MatchNuke extends command_1.Command {
9
9
  constructor() {
10
10
  super(...arguments);
11
11
  this.askForMissingFields = async (flags) => {
12
12
  const questions = [];
13
13
  if (!flags.client) {
14
- const clients = utils_1.getDirectories('./fastlane/clients');
14
+ const clients = common_1.getDirectories('./fastlane/clients');
15
15
  if (clients.length > 0) {
16
16
  questions.push({
17
17
  type: 'list',
@@ -52,6 +52,9 @@ MatchNuke.examples = [
52
52
  ];
53
53
  MatchNuke.flags = {
54
54
  help: command_1.flags.help({ char: 'h' }),
55
- client: command_1.flags.string({ char: 'c', description: 'Select client that you want to sync udids' }),
55
+ client: command_1.flags.string({
56
+ char: 'c',
57
+ description: 'Select client that you want to sync udids',
58
+ }),
56
59
  };
57
60
  MatchNuke.args = [{ name: 'build' }];
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/command';
2
+ export default class Setup extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
7
+ };
8
+ static args: {
9
+ name: string;
10
+ }[];
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable complexity */
4
+ /* eslint-disable no-negated-condition */
5
+ const command_1 = require("@oclif/command");
6
+ const inquirer = require("inquirer");
7
+ const path = require("path");
8
+ const app_icon_1 = require("../utils/setup/app-icon");
9
+ const launch_screen_1 = require("../utils/setup/launch-screen");
10
+ const client_1 = require("../utils/setup/client");
11
+ const env_1 = require("../utils/env");
12
+ const apple_1 = require("../utils/setup/apple");
13
+ const onesignal_1 = require("../utils/setup/onesignal");
14
+ class Setup extends command_1.Command {
15
+ async run() {
16
+ const envVars = env_1.readEnvVars(path.join(process.cwd(), 'template/env.template'));
17
+ const questions = [
18
+ {
19
+ type: 'input',
20
+ name: 'client',
21
+ message: 'What is client name (slug)?',
22
+ validate: (input) => {
23
+ return new Promise(resolve => {
24
+ if (!input) {
25
+ resolve('You need to input client');
26
+ }
27
+ else {
28
+ resolve(true);
29
+ }
30
+ });
31
+ },
32
+ },
33
+ ];
34
+ const { client } = await inquirer.prompt(questions);
35
+ const { bundleId, applicationId, appName } = await client_1.createClientConfig(client);
36
+ env_1.setEnvValue('CLIENT', client, envVars);
37
+ env_1.setEnvValue('BUNDLE_ID', bundleId, envVars);
38
+ env_1.setEnvValue('APPLICATION_ID', applicationId, envVars);
39
+ const deeplinkHost = envVars.DEEP_LINK_HOST.value.replace('[client]', client);
40
+ env_1.setEnvValue('DEEP_LINK_HOST', deeplinkHost, envVars);
41
+ const { appleTeamId, itcTeamId } = await apple_1.getAppleTeam();
42
+ if (appleTeamId) {
43
+ env_1.setEnvValue('APPLE_TEAM_ID', appleTeamId, envVars);
44
+ }
45
+ const iosAssetFolder = path.join(process.cwd(), `/ios/edular/assets/${client}`);
46
+ const androidAssetFolder = path.join(process.cwd(), `/android/app/src/${client}/res`);
47
+ // Create client env files
48
+ // shell.exec(`mkdir configs/${client}`);
49
+ await app_icon_1.prepareAppIcon({
50
+ iosAssetFolder,
51
+ });
52
+ const { launchScreen, launchScreenColor } = await launch_screen_1.prepareLaunchScreen({
53
+ iosAssetFolder,
54
+ androidAssetFolder,
55
+ });
56
+ if (launchScreen) {
57
+ env_1.setEnvValue('LAUNCH_SCREEN', launchScreen === 'icon' ? 'IconBootSplash' : 'FullScreenBootSplash', envVars);
58
+ }
59
+ if (launchScreenColor) {
60
+ env_1.setEnvValue('LAUNCH_SCREEN_BACKGROUND_COLOR', launchScreenColor, envVars);
61
+ }
62
+ // Onesignal
63
+ const { onesignal } = await onesignal_1.prepareOneSignal();
64
+ if (onesignal) {
65
+ env_1.setEnvValue('ONESIGNAL_APP_ID', onesignal, envVars);
66
+ }
67
+ // Store dev env
68
+ env_1.setEnvValue('ENV', 'dev', envVars);
69
+ const devEnvVars = env_1.updateServiceDomain(envVars, 'app');
70
+ env_1.setEnvValue('APP_NAME', `${appName} Dev`, devEnvVars);
71
+ env_1.saveEnvValues(devEnvVars, path.join(process.cwd(), `/configs/${client}/.env.dev`));
72
+ // Store staging env
73
+ env_1.setEnvValue('ENV', 'staging', envVars);
74
+ const stagingEnvVars = env_1.updateServiceDomain(envVars, 'app');
75
+ env_1.setEnvValue('APP_NAME', `${appName} Staging`, stagingEnvVars);
76
+ env_1.saveEnvValues(stagingEnvVars, path.join(process.cwd(), `/configs/${client}/.env.staging`));
77
+ // Store prod env
78
+ env_1.setEnvValue('ENV', 'prod', envVars);
79
+ const prodEnvVars = env_1.updateServiceDomain(envVars, 'app');
80
+ env_1.setEnvValue('APP_NAME', appName, prodEnvVars);
81
+ env_1.saveEnvValues(prodEnvVars, path.join(process.cwd(), `/configs/${client}/.env.prod`));
82
+ }
83
+ }
84
+ exports.default = Setup;
85
+ Setup.description = 'Setup new client';
86
+ Setup.examples = [
87
+ `$ rnbuilder build
88
+ hello world from ./src/setup.ts!
89
+ `,
90
+ ];
91
+ Setup.flags = {
92
+ help: command_1.flags.help({ char: 'h' }),
93
+ };
94
+ Setup.args = [{ name: 'setup' }];
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const command_1 = require("@oclif/command");
5
5
  const shell = require("shelljs");
6
6
  const inquirer = require("inquirer");
7
- const utils_1 = require("../utils");
7
+ const common_1 = require("../utils/common");
8
8
  class FirebaseSyncUDIDs extends command_1.Command {
9
9
  constructor() {
10
10
  super(...arguments);
11
11
  this.askForMissingFields = async (flags) => {
12
12
  const questions = [];
13
13
  if (!flags.client) {
14
- const clients = utils_1.getDirectories('./fastlane/clients');
14
+ const clients = common_1.getDirectories('./fastlane/clients');
15
15
  if (clients.length > 0) {
16
16
  questions.push({
17
17
  type: 'list',
@@ -50,6 +50,9 @@ FirebaseSyncUDIDs.examples = [
50
50
  ];
51
51
  FirebaseSyncUDIDs.flags = {
52
52
  help: command_1.flags.help({ char: 'h' }),
53
- client: command_1.flags.string({ char: 'c', description: 'Select client that you want to sync udids' }),
53
+ client: command_1.flags.string({
54
+ char: 'c',
55
+ description: 'Select client that you want to sync udids',
56
+ }),
54
57
  };
55
58
  FirebaseSyncUDIDs.args = [{ name: 'build' }];
@@ -4,3 +4,5 @@ export declare const getAppVersion: (env: string, client?: string | undefined, t
4
4
  version: string;
5
5
  build: number;
6
6
  };
7
+ export declare const copyDir: (src: string, dest: string) => Promise<unknown>;
8
+ export declare const normalise: (input: string) => string;
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAppVersion = exports.getDirectories = exports.buildKeyValuePairs = void 0;
3
+ exports.normalise = exports.copyDir = exports.getAppVersion = exports.getDirectories = exports.buildKeyValuePairs = void 0;
4
4
  const fs = require("fs");
5
5
  exports.buildKeyValuePairs = (params) => Object.keys(params).map(key => `${key}:${params[key]}`);
6
6
  exports.getDirectories = (path) => {
7
7
  try {
8
- const directories = fs.readdirSync(path).filter(file => fs.statSync(`${path}/${file}`).isDirectory());
8
+ const directories = fs
9
+ .readdirSync(path)
10
+ .filter(file => fs.statSync(`${path}/${file}`).isDirectory());
9
11
  return directories;
10
12
  }
11
- catch (error) {
12
- }
13
+ catch (error) { }
13
14
  return [];
14
15
  };
15
16
  const defaultVersion = {
@@ -34,3 +35,14 @@ exports.getAppVersion = (env, client, target = 'ios') => {
34
35
  }
35
36
  return version;
36
37
  };
38
+ exports.copyDir = (src, dest) => new Promise((resolve, reject) => {
39
+ fs.cp(src, dest, { recursive: true }, (err) => {
40
+ if (err) {
41
+ reject(err);
42
+ }
43
+ else {
44
+ resolve(true);
45
+ }
46
+ });
47
+ });
48
+ exports.normalise = (input) => input.replace(/'/g, '').trim();
@@ -0,0 +1,20 @@
1
+ export declare const readEnvVars: (envFilePath: string) => any;
2
+ /**
3
+ * Updates value for existing key or creates a new key=value line
4
+ *
5
+ * This function is a modified version of https://stackoverflow.com/a/65001580/3153583
6
+ *
7
+ * @param {string} key Key to update/insert
8
+ * @param {string} value Value to update/insert
9
+ */
10
+ export declare const saveEnvValues: (newValues: any, destFilePath: string) => void;
11
+ /**
12
+ * Updates value for existing key or creates a new key=value line
13
+ *
14
+ * This function is a modified version of https://stackoverflow.com/a/65001580/3153583
15
+ *
16
+ * @param {string} key Key to update/insert
17
+ * @param {string} value Value to update/insert
18
+ */
19
+ export declare const setEnvValue: (key: string, value: string, envVars: any) => void;
20
+ export declare const updateServiceDomain: (envVars: any, domain: string) => any[];
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateServiceDomain = exports.setEnvValue = exports.saveEnvValues = exports.readEnvVars = void 0;
4
+ /* eslint-disable no-negated-condition */
5
+ const fs = require("fs");
6
+ const os = require("os");
7
+ const path = require("path");
8
+ // read .env file & convert to array
9
+ exports.readEnvVars = (envFilePath) => {
10
+ const envVars = fs.readFileSync(envFilePath, 'utf-8').split(os.EOL);
11
+ const envObject = {};
12
+ envVars.forEach((line, index) => {
13
+ if (!line) {
14
+ return;
15
+ }
16
+ const result = line.split('=');
17
+ envObject[result[0]] = {
18
+ key: result[0],
19
+ value: result[1],
20
+ order: index,
21
+ };
22
+ });
23
+ return envObject;
24
+ };
25
+ /**
26
+ * Updates value for existing key or creates a new key=value line
27
+ *
28
+ * This function is a modified version of https://stackoverflow.com/a/65001580/3153583
29
+ *
30
+ * @param {string} key Key to update/insert
31
+ * @param {string} value Value to update/insert
32
+ */
33
+ exports.saveEnvValues = (newValues, destFilePath) => {
34
+ const payload = Object.values(newValues)
35
+ .sort((a, b) => a.order - b.order)
36
+ .map((data) => `${data.key}=${data.value}`);
37
+ // write everything back to the file system
38
+ const dirname = path.dirname(destFilePath);
39
+ fs.mkdirSync(dirname, { recursive: true });
40
+ fs.writeFileSync(destFilePath, payload.join(os.EOL));
41
+ };
42
+ /**
43
+ * Updates value for existing key or creates a new key=value line
44
+ *
45
+ * This function is a modified version of https://stackoverflow.com/a/65001580/3153583
46
+ *
47
+ * @param {string} key Key to update/insert
48
+ * @param {string} value Value to update/insert
49
+ */
50
+ exports.setEnvValue = (key, value, envVars) => {
51
+ envVars[key] = Object.assign(Object.assign({}, envVars[key]), { value });
52
+ };
53
+ exports.updateServiceDomain = (envVars, domain) => {
54
+ return Object.keys(envVars).map(key => {
55
+ var _a;
56
+ const data = envVars[key];
57
+ if ((_a = data.value) === null || _a === void 0 ? void 0 : _a.includes('[domain]')) {
58
+ return Object.assign(Object.assign({}, data), { value: data.value.replace('[domain]', domain) });
59
+ }
60
+ return data;
61
+ });
62
+ };
@@ -0,0 +1 @@
1
+ export declare const prepareAppIcon: ({ iosAssetFolder }: any) => Promise<void>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareAppIcon = void 0;
4
+ const inquirer = require("inquirer");
5
+ const path = require("path");
6
+ const sharp = require("sharp");
7
+ const common_1 = require("../common");
8
+ exports.prepareAppIcon = async ({ iosAssetFolder }) => {
9
+ const questions = [
10
+ {
11
+ type: 'confirm',
12
+ name: 'android-icon',
13
+ message: 'It is recommend to use Android Studio to create App icon and notification icon for android',
14
+ },
15
+ {
16
+ type: 'input',
17
+ name: 'appIconFile',
18
+ message: 'App Icon file for iOS?',
19
+ },
20
+ ];
21
+ const { appIconFile } = await inquirer.prompt(questions);
22
+ if (appIconFile) {
23
+ // Generate app icon for ios
24
+ // Copy template files
25
+ await common_1.copyDir('./template/AppIcon.appiconset', path.join(iosAssetFolder, 'AppIcon.appiconset'));
26
+ await sharp(common_1.normalise(appIconFile))
27
+ .resize(1024, 1024)
28
+ .png()
29
+ .toFile(path.join(iosAssetFolder, 'AppIcon.appiconset/ItunesArtwork@2x.png'));
30
+ }
31
+ };
@@ -0,0 +1 @@
1
+ export declare const getAppleTeam: () => Promise<any>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAppleTeam = void 0;
4
+ const inquirer = require("inquirer");
5
+ const shell = require("shelljs");
6
+ exports.getAppleTeam = async () => {
7
+ const { account } = await inquirer.prompt([
8
+ {
9
+ type: 'input',
10
+ name: 'account',
11
+ message: 'What is Apple account?',
12
+ },
13
+ ]);
14
+ if (!account) {
15
+ return {};
16
+ }
17
+ const { team } = await inquirer.prompt([
18
+ {
19
+ type: 'input',
20
+ name: 'team',
21
+ message: 'What is Apple team name?',
22
+ },
23
+ ]);
24
+ shell.exec(`fastlane get_team_names search:${team} id:${account}`);
25
+ return inquirer.prompt([
26
+ {
27
+ type: 'input',
28
+ name: 'appleTeamId',
29
+ message: 'What is Developer Team Id?',
30
+ },
31
+ {
32
+ type: 'input',
33
+ name: 'itcTeamId',
34
+ message: 'What is Appstore Connect Team Id?',
35
+ },
36
+ ]);
37
+ };
@@ -0,0 +1,3 @@
1
+ export declare const createClientConfig: (client: string) => Promise<any> & {
2
+ ui: import("inquirer/lib/ui/prompt");
3
+ };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createClientConfig = void 0;
4
+ const inquirer = require("inquirer");
5
+ exports.createClientConfig = (client) => {
6
+ return inquirer.prompt([
7
+ {
8
+ type: 'confirm',
9
+ name: 'android-client',
10
+ message: `Please add **${client}** to **productFlavors** in android>app>build.gradle`,
11
+ },
12
+ {
13
+ type: 'confirm',
14
+ name: 'ios-client',
15
+ message: `Please add **${client} prod** scheme and config`,
16
+ },
17
+ {
18
+ type: 'input',
19
+ name: 'appName',
20
+ message: 'What is app name?',
21
+ },
22
+ {
23
+ type: 'input',
24
+ name: 'bundleId',
25
+ message: 'What is bundle id?',
26
+ default: `com.edular.${client}`,
27
+ },
28
+ {
29
+ type: 'input',
30
+ name: 'applicationId',
31
+ message: 'What is application id (this is for android in case you need difference id for platforms)?',
32
+ default: `com.edular.${client}`,
33
+ },
34
+ ]);
35
+ };
@@ -0,0 +1,4 @@
1
+ export declare const prepareLaunchScreen: ({ iosAssetFolder, androidAssetFolder, }: any) => Promise<{
2
+ launchScreen: any;
3
+ launchScreenColor: any;
4
+ }>;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareLaunchScreen = void 0;
4
+ const sharp = require("sharp");
5
+ const path = require("path");
6
+ const inquirer = require("inquirer");
7
+ const common_1 = require("../common");
8
+ exports.prepareLaunchScreen = async ({ iosAssetFolder, androidAssetFolder, }) => {
9
+ const questions = [
10
+ {
11
+ type: 'list',
12
+ name: 'launchScreen',
13
+ message: 'What is the launch screen?',
14
+ // @ts-ignore
15
+ choices: [
16
+ {
17
+ name: 'Icon in the middle',
18
+ value: 'icon',
19
+ },
20
+ {
21
+ name: 'Image fullscreen',
22
+ value: 'fullscreen',
23
+ },
24
+ ],
25
+ },
26
+ {
27
+ type: 'input',
28
+ name: 'launchScreenFile',
29
+ message: 'Launch screen file (1400 x1867 for fullscreen)?',
30
+ },
31
+ {
32
+ type: 'input',
33
+ name: 'launchScreenColor',
34
+ message: 'Launch screen background hex color?',
35
+ default: '#ffffff',
36
+ },
37
+ ];
38
+ const { launchScreen, launchScreenFile, launchScreenColor } = await inquirer.prompt(questions);
39
+ const inputFile = common_1.normalise(launchScreenFile);
40
+ // Copy template files
41
+ if (launchScreen === 'icon') {
42
+ await common_1.copyDir('./template/BootSplashLogo.imageset', path.join(iosAssetFolder, 'BootSplashLogo.imageset'));
43
+ if (inputFile) {
44
+ await sharp(inputFile)
45
+ .resize(512, 512)
46
+ .png()
47
+ .toFile(path.join(iosAssetFolder, 'BootSplashLogo.imageset/bootsplash_logo.png'));
48
+ // iOS
49
+ await sharp(inputFile)
50
+ .resize({
51
+ width: 512,
52
+ })
53
+ .png()
54
+ .toFile(path.join(iosAssetFolder, 'BootSplashLogo.imageset/bootsplash_logo.png'));
55
+ // Android
56
+ await Promise.all([
57
+ sharp(inputFile)
58
+ .resize({
59
+ width: 1024,
60
+ })
61
+ .png()
62
+ .toFile(path.join(androidAssetFolder, 'mipmap-xxxhdpi/bootsplash_logo.png')),
63
+ sharp(inputFile)
64
+ .resize({
65
+ width: 768,
66
+ })
67
+ .png()
68
+ .toFile(path.join(androidAssetFolder, 'mipmap-xxhdpi/bootsplash_logo.png')),
69
+ sharp(inputFile)
70
+ .resize({
71
+ width: 512,
72
+ })
73
+ .png()
74
+ .toFile(path.join(androidAssetFolder, 'mipmap-xhdpi/bootsplash_logo.png')),
75
+ sharp(inputFile)
76
+ .resize({
77
+ width: 384,
78
+ })
79
+ .png()
80
+ .toFile(path.join(androidAssetFolder, 'mipmap-hdpi/bootsplash_logo.png')),
81
+ sharp(inputFile)
82
+ .resize({
83
+ width: 341,
84
+ })
85
+ .png()
86
+ .toFile(path.join(androidAssetFolder, 'mipmap-mdpi/bootsplash_logo.png')),
87
+ ]);
88
+ }
89
+ }
90
+ else if (launchScreen === 'fullscreen') {
91
+ await common_1.copyDir('./template/BootSplashImage.imageset', path.join(iosAssetFolder, 'BootSplashImage.imageset'));
92
+ if (inputFile) {
93
+ await sharp(inputFile)
94
+ .resize(512, 512)
95
+ .png()
96
+ .toFile(path.join(iosAssetFolder, 'BootSplashImage.imageset/splashTablet.png'));
97
+ }
98
+ }
99
+ return { launchScreen, launchScreenColor };
100
+ };
@@ -0,0 +1,3 @@
1
+ export declare const prepareOneSignal: () => Promise<any> & {
2
+ ui: import("inquirer/lib/ui/prompt");
3
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareOneSignal = void 0;
4
+ const inquirer = require("inquirer");
5
+ exports.prepareOneSignal = () => {
6
+ return inquirer.prompt([
7
+ {
8
+ type: 'input',
9
+ name: 'onesignal',
10
+ message: 'What is OneSignal App Id?',
11
+ },
12
+ ]);
13
+ };
@@ -1 +1 @@
1
- {"version":"0.5.22","commands":{"build":{"id":"build","description":"Build react native apps","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder build\nhello world from ./src/build.ts!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"client":{"name":"client","type":"option","char":"c","description":"Set client that you want to build app"},"target":{"name":"target","type":"option","char":"t","description":"Set the build target: android, ios or both","options":["android","ios"]},"env":{"name":"env","type":"option","char":"e","description":"Set the environment: prod, adhoc, staging","options":["staging","adhoc","prod"]},"branch":{"name":"branch","type":"option","char":"b","description":"Set the source branch used to build the app"},"version":{"name":"version","type":"option","char":"v","description":"Set the version number for this build"},"installr":{"name":"installr","type":"option","char":"i","description":"If enabled, the build will be uploaded to installR"}},"args":[{"name":"build"}]},"codepush":{"id":"codepush","description":"Push changes to existing apps","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder codepush\n Push changes to existing apps ./src/firebase-sync-udids.ts!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"client":{"name":"client","type":"option","char":"c","description":"Select client that you want to push update"}},"args":[{"name":"build"}]},"initialize":{"id":"initialize","description":"Initialize the environment for first run","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder initialize\ninitialize environment for first run from ./src/initialize.ts!\n"],"flags":{},"args":[]},"match-nuke":{"id":"match-nuke","description":"Nuke certificates","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder match-nuke\n Nuke certificates ./src/match-nuke.ts!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"client":{"name":"client","type":"option","char":"c","description":"Select client that you want to sync udids"}},"args":[{"name":"build"}]},"sync-udids":{"id":"sync-udids","description":"Sync device UDIDs from firebase","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder sync-udids\n Sync device UDIDs from firebase from ./src/firebase-sync-udids.ts!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"client":{"name":"client","type":"option","char":"c","description":"Select client that you want to sync udids"}},"args":[{"name":"build"}]}}}
1
+ {"version":"0.5.24","commands":{"build":{"id":"build","description":"Build react native apps","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder build\nhello world from ./src/build.ts!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"client":{"name":"client","type":"option","char":"c","description":"Set client that you want to build app"},"target":{"name":"target","type":"option","char":"t","description":"Set the build target: android, ios or both","options":["android","ios"]},"env":{"name":"env","type":"option","char":"e","description":"Set the environment: prod, adhoc, staging","options":["staging","adhoc","prod"]},"branch":{"name":"branch","type":"option","char":"b","description":"Set the source branch used to build the app"},"version":{"name":"version","type":"option","char":"v","description":"Set the version number for this build"},"installr":{"name":"installr","type":"option","char":"i","description":"If enabled, the build will be uploaded to installR"}},"args":[{"name":"build"}]},"codepush":{"id":"codepush","description":"Push changes to existing apps","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder codepush\n Push changes to existing apps ./src/firebase-sync-udids.ts!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"client":{"name":"client","type":"option","char":"c","description":"Select client that you want to push update"}},"args":[{"name":"build"}]},"initialize":{"id":"initialize","description":"Initialize the environment for first run","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder initialize\ninitialize environment for first run from ./src/initialize.ts!\n"],"flags":{},"args":[]},"match-nuke":{"id":"match-nuke","description":"Nuke certificates","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder match-nuke\n Nuke certificates ./src/match-nuke.ts!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"client":{"name":"client","type":"option","char":"c","description":"Select client that you want to sync udids"}},"args":[{"name":"build"}]},"setup":{"id":"setup","description":"Setup new client","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder build\nhello world from ./src/setup.ts!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"setup"}]},"sync-udids":{"id":"sync-udids","description":"Sync device UDIDs from firebase","pluginName":"rnbuilder","pluginType":"core","aliases":[],"examples":["$ rnbuilder sync-udids\n Sync device UDIDs from firebase from ./src/firebase-sync-udids.ts!\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"client":{"name":"client","type":"option","char":"c","description":"Select client that you want to sync udids"}},"args":[{"name":"build"}]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rnbuilder",
3
3
  "description": "React Native builder tool",
4
- "version": "0.5.22",
4
+ "version": "0.5.24",
5
5
  "author": "Tuan Luong @r0b0t3d",
6
6
  "bin": {
7
7
  "rnbuilder": "./bin/run"
@@ -14,6 +14,7 @@
14
14
  "dotenv": "^10.0.0",
15
15
  "inquirer": "^8.0.0",
16
16
  "inquirer-checkbox-plus-prompt": "^1.4.1",
17
+ "sharp": "^0.31.3",
17
18
  "shelljs": "^0.8.4",
18
19
  "tslib": "^1"
19
20
  },
@@ -23,7 +24,8 @@
23
24
  "@types/chai": "^4",
24
25
  "@types/inquirer": "^7.3.1",
25
26
  "@types/mocha": "^5",
26
- "@types/node": "^10",
27
+ "@types/node": "18.11.18",
28
+ "@types/sharp": "^0.31.1",
27
29
  "@types/shelljs": "^0.8.8",
28
30
  "chai": "^4",
29
31
  "eslint": "^5.13",
@@ -36,7 +38,7 @@
36
38
  "typescript": "^3.3"
37
39
  },
38
40
  "engines": {
39
- "node": ">=8.0.0"
41
+ "node": ">=16.7.0"
40
42
  },
41
43
  "files": [
42
44
  "/bin",