@mono-labs/cli 0.0.120 → 0.0.122
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/lib/app.js +0 -1
- package/lib/commands/build/index.js +3 -8
- package/lib/commands/build-process/cliFactory.js +7 -29
- package/lib/commands/build-process/dataLayer.js +19 -5
- package/lib/commands/build-process/index.js +0 -2
- package/lib/commands/build-process/runHasteCommand.js +9 -9
- package/lib/commands/build-process/runners/processManager.js +0 -1
- package/lib/commands/build-process/runners/runBackground.js +1 -3
- package/lib/commands/build-process/runners/runForeground.js +2 -5
- package/lib/commands/build-process/test.js +4 -15
- package/lib/commands/deploy/index.js +33 -36
- package/lib/commands/destroy.js +2 -3
- package/lib/commands/dev/dev-editor.js +14 -14
- package/lib/commands/dev/index.js +20 -20
- package/lib/commands/dev/ngrok.js +69 -69
- package/lib/commands/generate/generateSeed.js +100 -101
- package/lib/commands/init/index.js +1 -4
- package/lib/commands/prune/prune.js +1 -1
- package/lib/commands/seed/import.js +16 -17
- package/lib/commands/submit/index.js +2 -6
- package/lib/commands/update/index.js +3 -8
- package/lib/index.js +8 -8
- package/package.json +1 -1
package/lib/app.js
CHANGED
|
@@ -34,16 +34,12 @@ program
|
|
|
34
34
|
.option('--os, --platform <string>', 'Platform to build', 'ios')
|
|
35
35
|
.option('-f, --force', 'Force build to target production server')
|
|
36
36
|
.action((str, options) => {
|
|
37
|
-
console.log('its me');
|
|
38
37
|
const platform = selectPlatform(str.platform);
|
|
39
38
|
const profile = selectProfile(str.d, str.p, str.live, str.profile);
|
|
40
39
|
const isDev = profile === 'development';
|
|
41
|
-
//
|
|
42
|
-
console.log(`Building ${platform} with profile ${'`'}${profile}${'`'}`);
|
|
43
|
-
console.log('\n\n\n');
|
|
40
|
+
//
|
|
44
41
|
|
|
45
42
|
const NEXT_FORCE_PROD = str.force || isDev ? 'false' : 'true';
|
|
46
|
-
console.log('NEXT_FORCE_PROD', NEXT_FORCE_PROD);
|
|
47
43
|
|
|
48
44
|
let envObj = generateEnvValues(NEXT_FORCE_PROD, '', false);
|
|
49
45
|
if (!isDev) {
|
|
@@ -53,11 +49,11 @@ program
|
|
|
53
49
|
const publicUrl = process.env.NEXT_PUBLIC_API_URL || `${STAGING_URL}`;
|
|
54
50
|
envObj.NEXT_PUBLIC_API_URL = publicUrl;
|
|
55
51
|
}
|
|
56
|
-
|
|
52
|
+
|
|
57
53
|
envObj.EAS_BUILD_PROFILE = profile; // your custom variable
|
|
58
54
|
|
|
59
55
|
const command = `mono app eas build --profile ${profile} --platform ${platform}`;
|
|
60
|
-
|
|
56
|
+
|
|
61
57
|
const child = spawn('yarn', [command], {
|
|
62
58
|
stdio: 'inherit',
|
|
63
59
|
shell: true, // required if using shell-style commands or cross-platform support
|
|
@@ -67,7 +63,6 @@ program
|
|
|
67
63
|
});
|
|
68
64
|
|
|
69
65
|
child.on('exit', (code) => {
|
|
70
|
-
console.log(`Process exited with code ${code}`);
|
|
71
66
|
process.exit(code ?? 0);
|
|
72
67
|
});
|
|
73
68
|
});
|
|
@@ -15,23 +15,17 @@ export function createConfigCommands() {
|
|
|
15
15
|
config
|
|
16
16
|
.command('set <key> <value>')
|
|
17
17
|
.description('Set a configuration value')
|
|
18
|
-
.action((key, value) => {
|
|
19
|
-
console.log(`Setting ${key} to ${value}`);
|
|
20
|
-
});
|
|
18
|
+
.action((key, value) => {});
|
|
21
19
|
|
|
22
20
|
config
|
|
23
21
|
.command('get <key>')
|
|
24
22
|
.description('Get a configuration value')
|
|
25
|
-
.action((key) => {
|
|
26
|
-
console.log(`Value of ${key} is ...`);
|
|
27
|
-
});
|
|
23
|
+
.action((key) => {});
|
|
28
24
|
|
|
29
25
|
config
|
|
30
26
|
.command('list')
|
|
31
27
|
.description('List all configuration values')
|
|
32
|
-
.action(() => {
|
|
33
|
-
console.log('Listing config...');
|
|
34
|
-
});
|
|
28
|
+
.action(() => {});
|
|
35
29
|
|
|
36
30
|
return config;
|
|
37
31
|
}
|
|
@@ -42,9 +36,7 @@ export function createCliCommands() {
|
|
|
42
36
|
tools
|
|
43
37
|
.command('prune')
|
|
44
38
|
.description('Prune unused branches in git')
|
|
45
|
-
.action(() => {
|
|
46
|
-
console.log('Pruning unused branches...');
|
|
47
|
-
});
|
|
39
|
+
.action(() => {});
|
|
48
40
|
|
|
49
41
|
return tools;
|
|
50
42
|
}
|
|
@@ -54,8 +46,6 @@ export function buildCommands(files) {
|
|
|
54
46
|
Object.entries(files).forEach(([commandName, configObject]) => {
|
|
55
47
|
const optionsData = configObject.options || {};
|
|
56
48
|
|
|
57
|
-
console.log('configObject:', JSON.stringify(configObject, null, 2));
|
|
58
|
-
|
|
59
49
|
let current = program
|
|
60
50
|
.command(commandName)
|
|
61
51
|
.description(configObject.description || 'Haste command');
|
|
@@ -97,12 +87,7 @@ export function buildCommands(files) {
|
|
|
97
87
|
current.action(async (arg, cmd) => {
|
|
98
88
|
let envDefaults = {};
|
|
99
89
|
|
|
100
|
-
console.log('args', arg);
|
|
101
|
-
console.log('cmd', cmd);
|
|
102
90
|
if (argInfo) {
|
|
103
|
-
console.log(argInfo);
|
|
104
|
-
console.log(argInfo.options);
|
|
105
|
-
console.log(arg ?? argInfo.default);
|
|
106
91
|
if (
|
|
107
92
|
argInfo &&
|
|
108
93
|
argInfo.options &&
|
|
@@ -126,29 +111,22 @@ export function buildCommands(files) {
|
|
|
126
111
|
envDefaults[item.name] = item.default;
|
|
127
112
|
}
|
|
128
113
|
});
|
|
129
|
-
console.log('optionsData:', optionsData);
|
|
130
114
|
|
|
131
|
-
console.log('optionsDataList:', optionsDataList);
|
|
132
115
|
// optionsData
|
|
133
116
|
// .filter((item) => item.default !== undefined)
|
|
134
117
|
// .forEach((item) => {
|
|
135
118
|
// envDefaults[item] = item.default;
|
|
136
119
|
// });
|
|
137
|
-
|
|
138
|
-
console.log('envDefaults', envDefaults);
|
|
139
|
-
console.log('cmd', cmd);
|
|
120
|
+
|
|
140
121
|
const optionVals = { ...envDefaults, ...(cmd.opts ? cmd.opts() : cmd) };
|
|
141
|
-
|
|
122
|
+
|
|
142
123
|
Object.keys(optionVals).forEach((k) => {
|
|
143
124
|
optionVals[k] = verifyOptionValue(k, optionVals[k], optionsData);
|
|
144
125
|
});
|
|
145
126
|
optionVals['prod'] = optionVals[config.prodFlag] || false;
|
|
146
|
-
console.log('optionVals after verify:', optionVals);
|
|
147
127
|
|
|
148
|
-
console.log('envDefaults', envDefaults);
|
|
149
128
|
const argVal = arg || configObject.argument?.default;
|
|
150
|
-
|
|
151
|
-
console.log('argVal:', argVal);
|
|
129
|
+
|
|
152
130
|
mergeData({ ...optionVals, arg: argVal });
|
|
153
131
|
await runHasteCommand(configObject, optionVals);
|
|
154
132
|
});
|
|
@@ -20,21 +20,35 @@ export function hasData(key) {
|
|
|
20
20
|
return Object.prototype.hasOwnProperty.call(dataLayer, key);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function replaceTokens(str) {
|
|
23
|
+
export function replaceTokens(str, env = {}) {
|
|
24
24
|
console.log('replaceTokens input:', str);
|
|
25
25
|
if (typeof str !== 'string') return str;
|
|
26
26
|
console.log('dataLayer:', dataLayer);
|
|
27
|
+
|
|
27
28
|
const rVal = str.replace(/\$\{([^}]+)\}/g, (m, k) => {
|
|
28
29
|
console.log('token:', k);
|
|
29
30
|
console.log('match:', m);
|
|
30
31
|
console.log('hasData:', hasData(k));
|
|
32
|
+
|
|
33
|
+
// ✅ 1. Priority: existing dataLayer replacement
|
|
31
34
|
if (hasData(k)) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
const val = getData(k);
|
|
36
|
+
console.log('getData:', val);
|
|
37
|
+
return String(val);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ✅ 2. Next: environment variable replacement
|
|
41
|
+
if (env && Object.prototype.hasOwnProperty.call(env, k)) {
|
|
42
|
+
const val = env[k];
|
|
43
|
+
console.log('env match:', k, '=>', val);
|
|
44
|
+
return String(val ?? '');
|
|
36
45
|
}
|
|
46
|
+
|
|
47
|
+
// ✅ 3. Fallback: replace with empty string
|
|
48
|
+
console.log('no match, returning empty string');
|
|
49
|
+
return '';
|
|
37
50
|
});
|
|
51
|
+
|
|
38
52
|
console.log('rVal:', rVal);
|
|
39
53
|
return rVal;
|
|
40
54
|
}
|
|
@@ -5,8 +5,6 @@ import { ensureSignalHandlers } from './runners/processManager.js';
|
|
|
5
5
|
import { program } from '../../app.js';
|
|
6
6
|
|
|
7
7
|
const { files, config, rootDir } = boot();
|
|
8
|
-
console.log('[build-process] root:', rootDir);
|
|
9
|
-
console.log('[build-process] commands discovered:', Object.keys(files));
|
|
10
8
|
|
|
11
9
|
ensureSignalHandlers();
|
|
12
10
|
buildCommands(files);
|
|
@@ -14,7 +14,7 @@ import path from 'node:path';
|
|
|
14
14
|
*/
|
|
15
15
|
export async function runHasteCommand(configObject, options = {}) {
|
|
16
16
|
const { config } = getHasteConfig();
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
const devConfig = configObject.environments?.dev ?? {};
|
|
19
19
|
|
|
20
20
|
// Usage:
|
|
@@ -53,18 +53,18 @@ export async function runHasteCommand(configObject, options = {}) {
|
|
|
53
53
|
const preactions = configObject.preactions ?? [];
|
|
54
54
|
const actions = configObject.actions ?? [];
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
`→ Executing haste command: ${configObject.name || 'Unnamed Command'}`
|
|
60
60
|
);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
64
|
|
|
65
65
|
// Run preactions sequentially
|
|
66
66
|
for (const cmd of preactions) {
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
await runForeground(cmd, envObj, options);
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -74,11 +74,11 @@ export async function runHasteCommand(configObject, options = {}) {
|
|
|
74
74
|
const fg = actions[actions.length - 1];
|
|
75
75
|
|
|
76
76
|
for (const cmd of bg) {
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
runBackground(cmd, envObj, options);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
try {
|
|
83
83
|
await runBackground(fg, envObj, options, true);
|
|
84
84
|
} finally {
|
|
@@ -20,13 +20,11 @@ export function runBackground(
|
|
|
20
20
|
const isWin = process.platform === 'win32';
|
|
21
21
|
|
|
22
22
|
// Replace ${field} tokens in env values using dataLayer
|
|
23
|
-
|
|
24
|
-
console.log('backgroundOptions', options);
|
|
23
|
+
|
|
25
24
|
const expandedEnv = createdExpandedEnv(envObj);
|
|
26
25
|
|
|
27
26
|
// Replace in command string
|
|
28
27
|
const outCmd = replaceTokens(cmd);
|
|
29
|
-
console.log('outCmd:', outCmd);
|
|
30
28
|
|
|
31
29
|
return new Promise((resolve, reject) => {
|
|
32
30
|
const child = spawn(outCmd, {
|
|
@@ -9,11 +9,8 @@ const TOKEN_RX = /\{out:(?<field>[^\s}]+)\s+(?<value>[^\s}]+)\}/g;
|
|
|
9
9
|
* of the form {out:field value} and stores them in the shared dataLayer.
|
|
10
10
|
*/
|
|
11
11
|
export function runForeground(cmd, envObj = {}, options = {}) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
console.log('envObj:', envObj);
|
|
15
|
-
const newCmd = replaceTokens(cmd);
|
|
16
|
-
console.log('outCmd:', newCmd);
|
|
12
|
+
const newCmd = replaceTokens(cmd, envObj);
|
|
13
|
+
|
|
17
14
|
return new Promise((resolve, reject) => {
|
|
18
15
|
let lastLine = '';
|
|
19
16
|
let buffer = '';
|
|
@@ -10,11 +10,9 @@ export function executeCommandsIfWorkspaceAction(
|
|
|
10
10
|
commands = [],
|
|
11
11
|
fullEnv
|
|
12
12
|
) {
|
|
13
|
-
console.log('commands', commands);
|
|
14
13
|
const { config } = getHasteConfig();
|
|
15
14
|
const workspacemap = config.workspace?.packageMaps || {};
|
|
16
|
-
|
|
17
|
-
console.log('we here');
|
|
15
|
+
|
|
18
16
|
const result = execSync('yarn workspaces list --json', { encoding: 'utf8' })
|
|
19
17
|
.trim()
|
|
20
18
|
.split('\n')
|
|
@@ -22,34 +20,25 @@ export function executeCommandsIfWorkspaceAction(
|
|
|
22
20
|
.filter((obj) => obj !== '.');
|
|
23
21
|
|
|
24
22
|
const workspaces = result.map((w) => w.name);
|
|
25
|
-
|
|
26
|
-
console.log('workspacemap', workspacemap !== undefined);
|
|
27
|
-
console.log('workspacemap:key', workspacemap[action[1]]);
|
|
23
|
+
|
|
28
24
|
const actualAction =
|
|
29
25
|
workspacemap ? workspacemap[action[1]] || action[1] : action[1];
|
|
30
|
-
console.log('actualAction', actualAction);
|
|
31
|
-
console.log('workspaces', workspaces);
|
|
32
|
-
console.log('action', action);
|
|
33
26
|
|
|
34
27
|
const rootJson = getRootJson();
|
|
35
28
|
const workspacesList = (rootJson.workspaces || []).map((item) =>
|
|
36
29
|
item.replace(/[\.\/\*]/g, '')
|
|
37
30
|
);
|
|
38
31
|
|
|
39
|
-
console.log('workspacesList', workspacesList);
|
|
40
|
-
|
|
41
|
-
console.log('unfiltered result', result);
|
|
42
32
|
const filteredResult =
|
|
43
33
|
result.filter((obj) => obj.name === actualAction)[0] || {};
|
|
44
|
-
|
|
34
|
+
|
|
45
35
|
const workingDirectory = filteredResult.location || '';
|
|
46
36
|
// Check if the action is a workspace action
|
|
47
37
|
if (action) {
|
|
48
38
|
// Execute each command in the context of the workspace
|
|
49
39
|
commands.forEach((cmd) => {
|
|
50
40
|
const finalCommand = cmd.replace(WorkSpaceDirectory, workingDirectory);
|
|
51
|
-
|
|
52
|
-
console.log('fullEnv:', fullEnv);
|
|
41
|
+
|
|
53
42
|
// Here you would add the logic to execute the command
|
|
54
43
|
execSync(finalCommand, {
|
|
55
44
|
stdio: 'inherit',
|
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
import { spawn } from 'child_process'
|
|
3
|
-
import { readFileSync } from 'fs'
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
4
|
|
|
5
|
-
import { program } from '../../app.js'
|
|
5
|
+
import { program } from '../../app.js';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
-
const packageJSON = JSON.parse(
|
|
7
|
+
const packageJSON = JSON.parse(
|
|
8
|
+
readFileSync(join(process.cwd(), 'package.json'), 'utf8')
|
|
9
|
+
);
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const awsObject = packageJSON['aws'] || {}
|
|
11
|
+
const awsObject = packageJSON['aws'] || {};
|
|
12
12
|
|
|
13
13
|
// const awsProfile = awsObject['profile'] || 'default'
|
|
14
|
-
const accountId = process.env.CDK_DEPLOY_ACCOUNT
|
|
15
|
-
const awsProfile = process.env.CDK_DEPLOY_PROFILE || 'default'
|
|
14
|
+
const accountId = process.env.CDK_DEPLOY_ACCOUNT;
|
|
15
|
+
const awsProfile = process.env.CDK_DEPLOY_PROFILE || 'default';
|
|
16
16
|
|
|
17
|
-
console.log('process.env', process.env)
|
|
18
|
-
console.log('CDK_DEPLOY_ACCOUNT', process.env.CDK_DEPLOY_PROFILE)
|
|
19
17
|
program
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
18
|
+
.command('deploy2')
|
|
19
|
+
.description('Execute cdk deploy command')
|
|
20
|
+
.argument('[<string>]', 'Environment to deploy')
|
|
21
|
+
.option('-d, --dev', 'Deploy to dev environment')
|
|
22
|
+
.option('-r, --region <region>', 'Region to deploy to')
|
|
23
|
+
.action((str, options) => {
|
|
24
|
+
const owner = str || 'dev';
|
|
25
|
+
const region = options.region || 'us-east-2';
|
|
26
|
+
|
|
27
|
+
const command = `workspace infra deploy`;
|
|
28
|
+
const inputs = `-c owner=${owner} -c region=${region}`;
|
|
29
|
+
|
|
30
|
+
const child = spawn('yarn', [`${command} ${inputs}`], {
|
|
31
|
+
stdio: 'inherit',
|
|
32
|
+
shell: true, // required if using shell-style commands or cross-platform support
|
|
33
|
+
env: {
|
|
34
|
+
AWS_PROFILE: awsProfile,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
38
|
+
child.on('exit', (code) => {
|
|
39
|
+
process.exit(code ?? 0);
|
|
40
|
+
});
|
|
41
|
+
});
|
package/lib/commands/destroy.js
CHANGED
|
@@ -11,17 +11,16 @@ program
|
|
|
11
11
|
.action((str, options) => {
|
|
12
12
|
const owner = str || 'dev';
|
|
13
13
|
const region = options.region || 'us-east-2';
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
const command = `workspace infra cdk destroy`;
|
|
16
16
|
const inputs = `-c owner=${owner} -c region=${region}`;
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
const child = spawn('yarn', [`${command} ${inputs}`], {
|
|
19
19
|
stdio: 'inherit',
|
|
20
20
|
shell: true, // required if using shell-style commands or cross-platform support
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
child.on('exit', (code) => {
|
|
24
|
-
console.log(`Process exited with code ${code}`);
|
|
25
24
|
process.exit(code ?? 0);
|
|
26
25
|
});
|
|
27
26
|
});
|
|
@@ -125,8 +125,8 @@ function childManager(
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
child.on('sigint', (code) => {
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
|
|
129
|
+
|
|
130
130
|
`\n${service.icon || '🔚'} ${service.name || 'Service'} exited with code ${code}`
|
|
131
131
|
);
|
|
132
132
|
if (restartCallback) restartCallback();
|
|
@@ -134,7 +134,7 @@ function childManager(
|
|
|
134
134
|
|
|
135
135
|
child.on('exit', (code) => {
|
|
136
136
|
if (!serviceSigInt[service.name] && restartCallback) {
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
`\n${service.icon || '🔚'} ${service.name || 'Service'} exited with code ${code}\n`
|
|
139
139
|
);
|
|
140
140
|
restartCallback();
|
|
@@ -168,7 +168,7 @@ export async function dev(_forceProd, useAtlas, argServices, stage) {
|
|
|
168
168
|
getPrepServices().forEach((key) => {
|
|
169
169
|
const { command, stdio } = devServices[key];
|
|
170
170
|
if (acceptedServices.includes(key)) {
|
|
171
|
-
|
|
171
|
+
|
|
172
172
|
const child = spawn(command, {
|
|
173
173
|
stdio: ['pipe', 'inherit', 'pipe'], // Read from terminal, but capture output
|
|
174
174
|
shell: true,
|
|
@@ -178,10 +178,10 @@ export async function dev(_forceProd, useAtlas, argServices, stage) {
|
|
|
178
178
|
});
|
|
179
179
|
if (key === 'app') {
|
|
180
180
|
child.on('sigint', () => {
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
});
|
|
183
183
|
child.on('exit', () => {
|
|
184
|
-
|
|
184
|
+
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -194,8 +194,8 @@ export async function dev(_forceProd, useAtlas, argServices, stage) {
|
|
|
194
194
|
try {
|
|
195
195
|
ngrokUrl = (await getNgrokUrl()) + '/';
|
|
196
196
|
} catch (e) {
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
|
|
198
|
+
|
|
199
199
|
await new Promise((res) => setTimeout(res, 2000)); // Delay before retry
|
|
200
200
|
}
|
|
201
201
|
}
|
|
@@ -214,8 +214,8 @@ export async function dev(_forceProd, useAtlas, argServices, stage) {
|
|
|
214
214
|
|
|
215
215
|
setTimeout(
|
|
216
216
|
() => {
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
|
|
218
|
+
|
|
219
219
|
getContinuedServices().forEach((key) => {
|
|
220
220
|
if (stage && key === 'app') {
|
|
221
221
|
startService(key, forceProd, ngrokUrl, stage, envObj);
|
|
@@ -230,7 +230,7 @@ export async function dev(_forceProd, useAtlas, argServices, stage) {
|
|
|
230
230
|
);
|
|
231
231
|
|
|
232
232
|
async function shutdown() {
|
|
233
|
-
|
|
233
|
+
|
|
234
234
|
for (const [key, child] of Object.entries(childProcesses)) {
|
|
235
235
|
if (
|
|
236
236
|
child &&
|
|
@@ -239,11 +239,11 @@ export async function dev(_forceProd, useAtlas, argServices, stage) {
|
|
|
239
239
|
devServices[key].continue &&
|
|
240
240
|
!['docker'].includes(key)
|
|
241
241
|
) {
|
|
242
|
-
|
|
242
|
+
|
|
243
243
|
await new Promise((resolve) => {
|
|
244
244
|
treeKill(child.pid, 'SIGTERM', (err) => {
|
|
245
245
|
if (!err) {
|
|
246
|
-
|
|
246
|
+
|
|
247
247
|
}
|
|
248
248
|
resolve();
|
|
249
249
|
});
|
|
@@ -271,6 +271,6 @@ export async function dev(_forceProd, useAtlas, argServices, stage) {
|
|
|
271
271
|
|
|
272
272
|
// Exit signal
|
|
273
273
|
process.on('exit', () => {
|
|
274
|
-
|
|
274
|
+
|
|
275
275
|
});
|
|
276
276
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { program } from '../../app.js'
|
|
2
|
-
import { dev } from './dev-editor.js'
|
|
1
|
+
import { program } from '../../app.js';
|
|
2
|
+
import { dev } from './dev-editor.js';
|
|
3
3
|
|
|
4
4
|
program
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
.command('dev2')
|
|
6
|
+
.description('Run local dev environment')
|
|
7
|
+
.option('-d, --dev', 'Deploy to dev environment')
|
|
8
|
+
.option('-a, --atlas', 'Region to deploy to')
|
|
9
|
+
.option('--app', 'Runs just the native app')
|
|
10
|
+
.option('--host', 'Runs just the backend host app')
|
|
11
|
+
.option('--stage', 'Connect to staging environment')
|
|
12
|
+
.action(async (str, options) => {
|
|
13
|
+
let services = undefined;
|
|
14
|
+
|
|
15
|
+
if (str.app || str.host) {
|
|
16
|
+
if (str.app) services = ['app'];
|
|
17
|
+
if (str.host) services = ['backend'];
|
|
18
|
+
}
|
|
19
|
+
const stage = str.stage || false;
|
|
20
|
+
|
|
21
|
+
dev(str.dev || false, str.atlas || false, services, stage);
|
|
22
|
+
});
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import http from 'http'
|
|
3
|
-
import https from 'https'
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import http from 'http';
|
|
3
|
+
import https from 'https';
|
|
4
4
|
|
|
5
5
|
// Define the path to your .env file
|
|
6
|
-
const envFilePath = '../.env'
|
|
6
|
+
const envFilePath = '../.env';
|
|
7
7
|
|
|
8
8
|
// Fetch the ngrok public URL from localhost:4040 (ngrok web interface)
|
|
9
9
|
export function getNgrokUrl() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const options = {
|
|
12
|
+
hostname: 'localhost',
|
|
13
|
+
port: 4040,
|
|
14
|
+
path: '/api/tunnels',
|
|
15
|
+
method: 'GET',
|
|
16
|
+
};
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const req = (options.port === 443 ? https : http).request(
|
|
19
|
+
options,
|
|
20
|
+
(res) => {
|
|
21
|
+
let data = '';
|
|
22
|
+
res.on('data', (chunk) => {
|
|
23
|
+
data += chunk;
|
|
24
|
+
});
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
res.on('end', () => {
|
|
27
|
+
try {
|
|
28
|
+
const jsonResponse = JSON.parse(data);
|
|
29
|
+
const publicUrl =
|
|
30
|
+
jsonResponse.tunnels && jsonResponse.tunnels[0]?.public_url;
|
|
31
|
+
if (publicUrl) {
|
|
32
|
+
resolve(publicUrl);
|
|
33
|
+
} else {
|
|
34
|
+
reject('Could not find public URL in the response');
|
|
35
|
+
}
|
|
36
|
+
} catch (err) {
|
|
37
|
+
reject('Error parsing JSON response');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
);
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
req.on('error', (error) => {
|
|
44
|
+
reject(error);
|
|
45
|
+
});
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
req.end();
|
|
48
|
+
});
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
// Update the .env file with the new NGROK_URL value
|
|
48
52
|
function updateEnvFile(ngrokUrl) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return
|
|
55
|
-
}
|
|
53
|
+
fs.readFile(envFilePath, 'utf8', (err, data) => {
|
|
54
|
+
if (err) {
|
|
55
|
+
console.error('Error reading .env file:', err);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
let newData;
|
|
60
|
+
if (data.includes('EXPO_PRIVATE_API_URL=')) {
|
|
61
|
+
// If NGROK_URL exists, replace it
|
|
62
|
+
newData = data.replace(
|
|
63
|
+
/EXPO_PRIVATE_API_URL=.*/,
|
|
64
|
+
`EXPO_PRIVATE_API_URL=${ngrokUrl}/`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
// If NGROK_URL doesn't exist, add it to the file
|
|
68
|
+
newData = `${data}\nEXPO_PRIVATE_API_URL=${ngrokUrl}/`;
|
|
69
|
+
}
|
|
58
70
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
console.log('newData', newData)
|
|
69
|
-
|
|
70
|
-
// Write the updated data back to the .env file
|
|
71
|
-
fs.writeFile(envFilePath, newData, 'utf8', (writeErr) => {
|
|
72
|
-
if (writeErr) {
|
|
73
|
-
console.error('Error writing to .env file:', writeErr)
|
|
74
|
-
} else {
|
|
75
|
-
console.log(`NGROK_URL has been updated to: ${ngrokUrl}`)
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
})
|
|
71
|
+
// Write the updated data back to the .env file
|
|
72
|
+
fs.writeFile(envFilePath, newData, 'utf8', (writeErr) => {
|
|
73
|
+
if (writeErr) {
|
|
74
|
+
console.error('Error writing to .env file:', writeErr);
|
|
75
|
+
} else {
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
79
|
}
|
|
80
80
|
// Main function to get the ngrok URL and update the .env file
|
|
81
81
|
export async function updateNgrokUrl() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
try {
|
|
83
|
+
const ngrokUrl = await getNgrokUrl();
|
|
84
|
+
updateEnvFile(ngrokUrl);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.error('Error:', error);
|
|
87
|
+
}
|
|
88
88
|
}
|
|
@@ -1,171 +1,167 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
1
|
+
import fs from 'fs';
|
|
2
2
|
// Initialize the DynamoDB client
|
|
3
3
|
|
|
4
|
-
import { readFileSync } from 'fs'
|
|
5
|
-
import path from 'path'
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
6
|
|
|
7
|
-
import { DynamoDBClient, ScanCommand } from '@aws-sdk/client-dynamodb'
|
|
8
|
-
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb'
|
|
7
|
+
import { DynamoDBClient, ScanCommand } from '@aws-sdk/client-dynamodb';
|
|
8
|
+
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
|
|
9
9
|
|
|
10
10
|
import { join } from 'node:path';
|
|
11
|
-
const packageJSON = JSON.parse(
|
|
11
|
+
const packageJSON = JSON.parse(
|
|
12
|
+
readFileSync(join(process.cwd(), 'package.json'), 'utf8')
|
|
13
|
+
);
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
const awsObject = packageJSON['aws'] || {};
|
|
16
|
+
const projectName = packageJSON['name'] || 'project';
|
|
14
17
|
|
|
15
|
-
const
|
|
16
|
-
const projectName = packageJSON['name'] || 'project'
|
|
17
|
-
|
|
18
|
-
const awsProfile = awsObject['profile'] || 'default'
|
|
18
|
+
const awsProfile = awsObject['profile'] || 'default';
|
|
19
19
|
|
|
20
20
|
// TODO: Fix Copy Issues
|
|
21
|
-
const dirPath = './docker/seed' // Folder path to delete files from
|
|
21
|
+
const dirPath = './docker/seed'; // Folder path to delete files from
|
|
22
22
|
|
|
23
23
|
// Function to delete all files in the specified directory (ignores directories)
|
|
24
24
|
function deleteFilesInDir(dir) {
|
|
25
25
|
// Read all files and directories inside the directory
|
|
26
|
-
const files = fs.readdirSync(dir)
|
|
26
|
+
const files = fs.readdirSync(dir);
|
|
27
27
|
|
|
28
28
|
// Loop through each file and directory
|
|
29
29
|
files.forEach((file) => {
|
|
30
|
-
const filePath = path.join(dir, file) // Get full path of the file or directory
|
|
30
|
+
const filePath = path.join(dir, file); // Get full path of the file or directory
|
|
31
31
|
|
|
32
32
|
// Check if it's a file (not a directory)
|
|
33
|
-
const stats = fs.statSync(filePath)
|
|
33
|
+
const stats = fs.statSync(filePath);
|
|
34
34
|
|
|
35
35
|
if (stats.isFile()) {
|
|
36
36
|
// If it's a file, delete it
|
|
37
|
-
fs.unlinkSync(filePath)
|
|
38
|
-
console.log(`Deleted file: ${filePath}`)
|
|
37
|
+
fs.unlinkSync(filePath);
|
|
39
38
|
}
|
|
40
|
-
})
|
|
39
|
+
});
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
// Function to scan the DynamoDB table and generate the desired JSON format
|
|
44
43
|
async function generateTableExport(tablename, client, profilesOnly = false) {
|
|
45
44
|
let params = {
|
|
46
45
|
TableName: tablename,
|
|
47
|
-
}
|
|
46
|
+
};
|
|
48
47
|
|
|
49
48
|
// This will hold all the data retrieved from DynamoDB
|
|
50
|
-
let allItems = []
|
|
51
|
-
let lastEvaluatedKey = null
|
|
49
|
+
let allItems = [];
|
|
50
|
+
let lastEvaluatedKey = null;
|
|
52
51
|
|
|
53
52
|
// If there are more items (pagination in case of large tables)
|
|
54
53
|
do {
|
|
55
54
|
if (lastEvaluatedKey) {
|
|
56
|
-
params.ExclusiveStartKey = lastEvaluatedKey
|
|
55
|
+
params.ExclusiveStartKey = lastEvaluatedKey;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
try {
|
|
60
59
|
// Perform the scan operation
|
|
61
|
-
|
|
62
|
-
const data = await client.send(new ScanCommand(params))
|
|
63
|
-
allItems = allItems.concat(data.Items)
|
|
64
|
-
lastEvaluatedKey = data.LastEvaluatedKey // Set the last evaluated key for pagination
|
|
60
|
+
|
|
61
|
+
const data = await client.send(new ScanCommand(params));
|
|
62
|
+
allItems = allItems.concat(data.Items);
|
|
63
|
+
lastEvaluatedKey = data.LastEvaluatedKey; // Set the last evaluated key for pagination
|
|
65
64
|
} catch (error) {
|
|
66
|
-
console.error('Error scanning DynamoDB table:', error)
|
|
67
|
-
return
|
|
65
|
+
console.error('Error scanning DynamoDB table:', error);
|
|
66
|
+
return;
|
|
68
67
|
}
|
|
69
|
-
} while (lastEvaluatedKey) // Continue scanning if there are more pages of results
|
|
68
|
+
} while (lastEvaluatedKey); // Continue scanning if there are more pages of results
|
|
70
69
|
|
|
71
70
|
// Format the data into the desired JSON structure
|
|
72
|
-
//
|
|
71
|
+
//
|
|
73
72
|
const formattedData = {
|
|
74
73
|
[tablename]: allItems
|
|
75
74
|
.filter(
|
|
76
75
|
(item) =>
|
|
77
76
|
!profilesOnly ||
|
|
78
77
|
!tablename.includes('Database') ||
|
|
79
|
-
unmarshall(item)['SK'].includes('PROFILE')
|
|
78
|
+
unmarshall(item)['SK'].includes('PROFILE')
|
|
80
79
|
)
|
|
81
80
|
.map((item) => {
|
|
82
|
-
const formattedItem = unmarshall(item) // Unmarshall DynamoDB format to JS object
|
|
81
|
+
const formattedItem = unmarshall(item); // Unmarshall DynamoDB format to JS object
|
|
83
82
|
// Ensure the correct format: PutRequest -> Item
|
|
84
83
|
//if (tablename.includes('Database') && !formattedItem['SK'].includes('USER')) return undefined;
|
|
85
84
|
return {
|
|
86
85
|
PutRequest: {
|
|
87
86
|
Item: marshall(formattedItem), // Marshall JS object back to DynamoDB format
|
|
88
87
|
},
|
|
89
|
-
}
|
|
88
|
+
};
|
|
90
89
|
}),
|
|
91
|
-
}
|
|
92
|
-
return formattedData
|
|
90
|
+
};
|
|
91
|
+
return formattedData;
|
|
93
92
|
}
|
|
94
93
|
async function exportDynamoTable(
|
|
95
94
|
tables,
|
|
96
95
|
client,
|
|
97
96
|
dbRewrites,
|
|
98
97
|
profilesOnly = false,
|
|
99
|
-
strOut = './docker/seed'
|
|
98
|
+
strOut = './docker/seed'
|
|
100
99
|
) {
|
|
101
|
-
deleteFilesInDir(dirPath)
|
|
100
|
+
deleteFilesInDir(dirPath);
|
|
102
101
|
let output = await Promise.all(
|
|
103
|
-
tables.map(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
tables.map(
|
|
103
|
+
async (tableName) =>
|
|
104
|
+
await generateTableExport(tableName, client, profilesOnly)
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
const fileName = `${strOut}/dynamodb-seed`;
|
|
108
|
+
|
|
109
|
+
const outputRes = {};
|
|
108
110
|
output.map((item) => {
|
|
109
|
-
const keys = Object.keys(item)
|
|
110
|
-
console.log(keys)
|
|
111
|
+
const keys = Object.keys(item);
|
|
111
112
|
|
|
112
113
|
return keys.map((key) => {
|
|
113
|
-
const value = item[key].filter((item) => item !== undefined)
|
|
114
|
-
outputRes[key] = value
|
|
115
|
-
return { value }
|
|
116
|
-
})
|
|
117
|
-
})
|
|
114
|
+
const value = item[key].filter((item) => item !== undefined);
|
|
115
|
+
outputRes[key] = value;
|
|
116
|
+
return { value };
|
|
117
|
+
});
|
|
118
|
+
});
|
|
118
119
|
|
|
119
|
-
output = outputRes
|
|
120
|
+
output = outputRes;
|
|
120
121
|
|
|
121
|
-
const fileObject = {}
|
|
122
|
-
const dbObject = {}
|
|
122
|
+
const fileObject = {};
|
|
123
|
+
const dbObject = {};
|
|
123
124
|
Object.keys(output).forEach((key) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
console.log('value', value.length)
|
|
125
|
+
const value = output[key];
|
|
126
|
+
|
|
127
127
|
if (value.length > 0) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
console.log('dbKey', dbKey)
|
|
132
|
-
dbObject[dbKey] = value
|
|
128
|
+
const dbKey = dbRewrites[key] || key;
|
|
129
|
+
|
|
130
|
+
dbObject[dbKey] = value;
|
|
133
131
|
}
|
|
134
|
-
})
|
|
135
|
-
console.log('dbObject', dbObject)
|
|
132
|
+
});
|
|
136
133
|
|
|
137
|
-
let countTotal = 0
|
|
134
|
+
let countTotal = 0;
|
|
138
135
|
|
|
139
136
|
Object.keys(dbObject).forEach((key) => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
const putItems = dbObject[key]
|
|
137
|
+
let currentPosition = 0;
|
|
138
|
+
const numOfItems = 20;
|
|
139
|
+
const putItems = dbObject[key];
|
|
144
140
|
while (currentPosition < putItems.length) {
|
|
145
141
|
if (dbObject[key].length > numOfItems) {
|
|
146
|
-
const result = putItems.slice(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
const result = putItems.slice(
|
|
143
|
+
currentPosition,
|
|
144
|
+
currentPosition + numOfItems
|
|
145
|
+
);
|
|
146
|
+
fileObject[`${fileName}-${countTotal}`] = { [key]: result };
|
|
147
|
+
currentPosition += numOfItems;
|
|
148
|
+
countTotal += 1;
|
|
150
149
|
} else {
|
|
151
|
-
const result = putItems.slice(currentPosition, putItems.length)
|
|
152
|
-
fileObject[`${fileName}-${countTotal}`] = { [key]: result }
|
|
153
|
-
currentPosition += numOfItems
|
|
154
|
-
countTotal += 1
|
|
150
|
+
const result = putItems.slice(currentPosition, putItems.length);
|
|
151
|
+
fileObject[`${fileName}-${countTotal}`] = { [key]: result };
|
|
152
|
+
currentPosition += numOfItems;
|
|
153
|
+
countTotal += 1;
|
|
155
154
|
}
|
|
156
155
|
}
|
|
157
|
-
})
|
|
156
|
+
});
|
|
158
157
|
|
|
159
158
|
Object.keys(fileObject).forEach((key) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
console.log(`Export complete. Data written to ${fileName}`)
|
|
159
|
+
fs.writeFileSync(`${key}.json`, JSON.stringify(fileObject[key], null, 2));
|
|
160
|
+
});
|
|
165
161
|
}
|
|
166
162
|
export function createDirIfNotExists(dirname) {
|
|
167
163
|
if (!fs.existsSync(dirname)) {
|
|
168
|
-
fs.mkdirSync(dirname)
|
|
164
|
+
fs.mkdirSync(dirname);
|
|
169
165
|
}
|
|
170
166
|
}
|
|
171
167
|
|
|
@@ -178,39 +174,42 @@ export function exportTable(
|
|
|
178
174
|
rewriteDb,
|
|
179
175
|
live = false,
|
|
180
176
|
region = 'us-east-2',
|
|
181
|
-
profilesOnly = false
|
|
177
|
+
profilesOnly = false
|
|
182
178
|
) {
|
|
183
|
-
createDirIfNotExists(dirPath)
|
|
184
|
-
const tables = live ? ['MainDatabase'] : ['MainDB']
|
|
185
|
-
const dbRewrites = {}
|
|
186
|
-
const dbOg = {}
|
|
187
|
-
tables.map((table, index) => (dbOg[table] = newTables[index] || ''))
|
|
179
|
+
createDirIfNotExists(dirPath);
|
|
180
|
+
const tables = live ? ['MainDatabase'] : ['MainDB'];
|
|
181
|
+
const dbRewrites = {};
|
|
182
|
+
const dbOg = {};
|
|
183
|
+
tables.map((table, index) => (dbOg[table] = newTables[index] || ''));
|
|
188
184
|
tables.map((table, index) => {
|
|
189
|
-
const rewriteDbIndex = rewriteDb[index]
|
|
185
|
+
const rewriteDbIndex = rewriteDb[index];
|
|
190
186
|
if (rewriteDbIndex === 'MainDB') {
|
|
191
|
-
dbRewrites[`${projectName}-infra-${table}-${owner}`] =
|
|
187
|
+
dbRewrites[`${projectName}-infra-${table}-${owner}`] =
|
|
188
|
+
`${rewriteDbIndex || table}`;
|
|
192
189
|
} else {
|
|
193
|
-
const newTable = tables[index].replace(
|
|
190
|
+
const newTable = tables[index].replace(
|
|
191
|
+
tables[index],
|
|
192
|
+
newTables[index] || tables[index]
|
|
193
|
+
);
|
|
194
194
|
dbRewrites[`${projectName}-infra-${table}-${owner}`] =
|
|
195
|
-
`${projectName}-infra-${newTable || table}-${altOwner || owner}
|
|
195
|
+
`${projectName}-infra-${newTable || table}-${altOwner || owner}`;
|
|
196
196
|
}
|
|
197
|
-
})
|
|
197
|
+
});
|
|
198
198
|
|
|
199
|
-
let dbTables = ['MainDB']
|
|
199
|
+
let dbTables = ['MainDB'];
|
|
200
200
|
|
|
201
201
|
if (live) {
|
|
202
202
|
dbTables = tables.map((table) => {
|
|
203
|
-
return `${projectName}-infra-${table}-${owner}
|
|
204
|
-
})
|
|
203
|
+
return `${projectName}-infra-${table}-${owner}`;
|
|
204
|
+
});
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
let client = undefined
|
|
207
|
+
let client = undefined;
|
|
208
208
|
if (live) {
|
|
209
209
|
client = new DynamoDBClient({
|
|
210
210
|
region: region, // Replace with your AWS region
|
|
211
|
-
})
|
|
211
|
+
});
|
|
212
212
|
} else {
|
|
213
|
-
console.log('LOCAL')
|
|
214
213
|
client = new DynamoDBClient({
|
|
215
214
|
region: region, // Replace with your AWS region
|
|
216
215
|
endpoint: 'http://localhost:8000', // The default local DynamoDB endpoint
|
|
@@ -218,7 +217,7 @@ export function exportTable(
|
|
|
218
217
|
accessKeyId: 'fakeAccessKeyId', // Use fake credentials for local DynamoDB
|
|
219
218
|
secretAccessKey: 'fakeSecretAccessKey',
|
|
220
219
|
},
|
|
221
|
-
})
|
|
220
|
+
});
|
|
222
221
|
}
|
|
223
|
-
exportDynamoTable(dbTables, client, dbRewrites, profilesOnly)
|
|
222
|
+
exportDynamoTable(dbTables, client, dbRewrites, profilesOnly);
|
|
224
223
|
}
|
|
@@ -9,8 +9,6 @@ const packageJSON = JSON.parse(
|
|
|
9
9
|
readFileSync(join(process.cwd(), 'package.json'), 'utf8')
|
|
10
10
|
);
|
|
11
11
|
|
|
12
|
-
console.log('Deploy command loaded');
|
|
13
|
-
|
|
14
12
|
const awsObject = packageJSON['aws'] || {};
|
|
15
13
|
|
|
16
14
|
const accountId = process.env.CDK_DEPLOY_ACCOUNT;
|
|
@@ -22,7 +20,7 @@ program
|
|
|
22
20
|
.action((str, options) => {
|
|
23
21
|
const owner = str || 'dev';
|
|
24
22
|
const region = options.region || 'us-east-2';
|
|
25
|
-
|
|
23
|
+
|
|
26
24
|
const command = `workspace infra cdk bootstrap`;
|
|
27
25
|
const child = spawn('yarn', [`${command}`], {
|
|
28
26
|
stdio: 'inherit',
|
|
@@ -33,7 +31,6 @@ program
|
|
|
33
31
|
});
|
|
34
32
|
|
|
35
33
|
child.on('exit', (code) => {
|
|
36
|
-
console.log(`Process exited with code ${code}`);
|
|
37
34
|
process.exit(code ?? 0);
|
|
38
35
|
});
|
|
39
36
|
});
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { execSync } from 'child_process'
|
|
2
|
-
import fs from 'fs'
|
|
3
|
-
import path from 'path'
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
4
|
|
|
5
5
|
export function importAllDynamoBatches(folderPath, useRemote = false) {
|
|
6
6
|
const files = fs
|
|
7
7
|
.readdirSync(folderPath)
|
|
8
|
-
.filter(
|
|
8
|
+
.filter(
|
|
9
|
+
(file) => file.startsWith('dynamodb-seed-') && file.endsWith('.json')
|
|
10
|
+
);
|
|
9
11
|
|
|
10
|
-
files.sort() // Optional: ensures files run in order
|
|
12
|
+
files.sort(); // Optional: ensures files run in order
|
|
11
13
|
|
|
12
14
|
for (const file of files) {
|
|
13
|
-
const fullPath = path.resolve(path.join(folderPath, file))
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
:
|
|
15
|
+
const fullPath = path.resolve(path.join(folderPath, file));
|
|
16
|
+
|
|
17
|
+
const baseCommand =
|
|
18
|
+
useRemote ?
|
|
19
|
+
`aws dynamodb batch-write-item --request-items file://${fullPath}`
|
|
20
|
+
: `aws dynamodb batch-write-item --endpoint-url http://localhost:8000 --request-items file://${fullPath}`;
|
|
19
21
|
try {
|
|
20
|
-
console.log('baseCommand:', baseCommand)
|
|
21
|
-
console.log(`Executing command: ${baseCommand}`)
|
|
22
22
|
execSync(baseCommand, {
|
|
23
23
|
stdio: 'inherit',
|
|
24
|
-
})
|
|
25
|
-
console.log(`✅ Successfully imported ${file}\n`)
|
|
24
|
+
});
|
|
26
25
|
} catch (err) {
|
|
27
|
-
console.error(`❌ Error with ${file}:`, err.message)
|
|
28
|
-
break // or continue if you want to skip failed files
|
|
26
|
+
console.error(`❌ Error with ${file}:`, err.message);
|
|
27
|
+
break; // or continue if you want to skip failed files
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
}
|
|
@@ -10,10 +10,7 @@ program
|
|
|
10
10
|
.option('--android', 'Build to target preview profile')
|
|
11
11
|
.option('--ios', 'Build to target production profile')
|
|
12
12
|
.action((str, options) => {
|
|
13
|
-
|
|
14
|
-
console.log('test');
|
|
15
|
-
//console.log(options);
|
|
16
|
-
console.log(str);
|
|
13
|
+
//
|
|
17
14
|
|
|
18
15
|
let envObj = generateEnvValues(true, '', false);
|
|
19
16
|
|
|
@@ -22,7 +19,7 @@ program
|
|
|
22
19
|
envObj.EAS_BUILD_PROFILE = 'production';
|
|
23
20
|
|
|
24
21
|
const command = `workspace app eas submit ${str.android ? `--platform android` : `--platform ios`}`;
|
|
25
|
-
|
|
22
|
+
|
|
26
23
|
const child = spawn('yarn', [command], {
|
|
27
24
|
stdio: 'inherit',
|
|
28
25
|
shell: true, // required if using shell-style commands or cross-platform support
|
|
@@ -32,7 +29,6 @@ program
|
|
|
32
29
|
});
|
|
33
30
|
|
|
34
31
|
child.on('exit', (code) => {
|
|
35
|
-
console.log(`Process exited with code ${code}`);
|
|
36
32
|
process.exit(code ?? 0);
|
|
37
33
|
});
|
|
38
34
|
});
|
|
@@ -14,7 +14,7 @@ program
|
|
|
14
14
|
.description('Prune local branches that are not on origin')
|
|
15
15
|
.option('--auto', 'Auto run')
|
|
16
16
|
.action(async (str) => {
|
|
17
|
-
//
|
|
17
|
+
//
|
|
18
18
|
|
|
19
19
|
const { auto } = str;
|
|
20
20
|
|
|
@@ -36,14 +36,11 @@ program
|
|
|
36
36
|
fastChild.stderr.on('data', (data) => {
|
|
37
37
|
process.stderr.write(data); // pipe errors
|
|
38
38
|
});
|
|
39
|
-
fastChild.on('message', (data) => {
|
|
40
|
-
console.log(`Message from child process: ${data}`);
|
|
41
|
-
});
|
|
39
|
+
fastChild.on('message', (data) => {});
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
const branches = getEASBranches().map((branch) => branch.name);
|
|
46
|
-
console.log('branches', branches);
|
|
47
44
|
|
|
48
45
|
const { branch } = await inquirer.prompt([
|
|
49
46
|
{
|
|
@@ -86,7 +83,5 @@ program
|
|
|
86
83
|
child.stderr.on('data', (data) => {
|
|
87
84
|
process.stderr.write(data); // pipe errors
|
|
88
85
|
});
|
|
89
|
-
child.on('message', (data) => {
|
|
90
|
-
console.log(`Message from child process: ${data}`);
|
|
91
|
-
});
|
|
86
|
+
child.on('message', (data) => {});
|
|
92
87
|
});
|
package/lib/index.js
CHANGED
|
@@ -23,7 +23,7 @@ const preactions = config.workspace?.preactions || [];
|
|
|
23
23
|
const envMapList = config.envMap ?? ['FAILURE'];
|
|
24
24
|
|
|
25
25
|
program.on('command:*', (operands) => {
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
const [cmd] = operands; // e.g. "destroy3"
|
|
28
28
|
const raw = program.rawArgs.slice(2); // after `node script.js`
|
|
29
29
|
const i = raw.indexOf(cmd);
|
|
@@ -31,30 +31,30 @@ program.on('command:*', (operands) => {
|
|
|
31
31
|
|
|
32
32
|
const workspace = workspacemap[tokens[0]] || tokens[0];
|
|
33
33
|
let rest = tokens.slice(1);
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
|
|
35
|
+
|
|
36
36
|
|
|
37
37
|
const envKeys = Object.keys(process.env).filter((k) => k.startsWith('MONO_'));
|
|
38
38
|
|
|
39
39
|
let envObj = {};
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
envKeys.map((k) => {
|
|
43
43
|
envMapList.map((item) => {
|
|
44
44
|
envObj[k.replace('MONO', item)] = process.env[k];
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
|
|
50
50
|
// If the “rest” is empty or starts with flags, insert a default script
|
|
51
51
|
|
|
52
52
|
const args = ['workspace', workspace, ...rest];
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
|
|
55
55
|
console.error(`Unknown command. Falling back to: yarn ${args.join(' ')}`);
|
|
56
56
|
executeCommandsIfWorkspaceAction(args, preactions, envObj);
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
stdio: 'inherit',
|
|
59
59
|
shell: process.platform === 'win32',
|
|
60
60
|
});
|
|
@@ -64,7 +64,7 @@ program.on('command:*', (operands) => {
|
|
|
64
64
|
env: { ...process.env, ...envObj },
|
|
65
65
|
});
|
|
66
66
|
child.on('exit', (code) => {
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
process.exitCode = code ?? 1;
|
|
69
69
|
});
|
|
70
70
|
});
|