@mono-labs/cli 0.0.238 → 0.0.242

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.
Files changed (179) hide show
  1. package/bin/mono.js +1 -1
  2. package/dist/index.js +32 -51
  3. package/dist/lib/app.js +52 -0
  4. package/dist/lib/commands/build-process/boot.js +12 -0
  5. package/dist/lib/commands/build-process/cliFactory.js +145 -0
  6. package/dist/lib/commands/build-process/dataLayer.js +56 -0
  7. package/dist/lib/commands/build-process/index.js +11 -0
  8. package/dist/lib/commands/build-process/readEnv.js +34 -0
  9. package/dist/lib/commands/build-process/runMonoCommand.js +82 -0
  10. package/dist/lib/commands/build-process/runners/processManager.js +45 -0
  11. package/dist/lib/commands/build-process/runners/runBackground.js +46 -0
  12. package/dist/lib/commands/build-process/runners/runForeground.js +52 -0
  13. package/dist/lib/commands/build-process/test.js +32 -0
  14. package/dist/lib/commands/build-process/testflag.js +4 -0
  15. package/dist/lib/commands/build-process/validators.js +17 -0
  16. package/dist/lib/commands/loadFromRoot.js +53 -0
  17. package/dist/lib/commands/prune/index.js +10 -0
  18. package/dist/lib/commands/prune/prune.js +49 -0
  19. package/dist/lib/config.js +6 -0
  20. package/dist/lib/filterUnwantedEnvVars.js +88 -0
  21. package/dist/lib/generateNewEnvList.js +17 -0
  22. package/dist/lib/index.js +49 -0
  23. package/dist/src/cdk/cdk.js +6 -0
  24. package/dist/src/cdk/index.js +17 -0
  25. package/dist/{expo.js → src/expo.js} +18 -34
  26. package/dist/src/index.js +56 -0
  27. package/dist/src/merge-env.js +25 -0
  28. package/dist/{project → src/project}/build-mono-readme.js +11 -20
  29. package/dist/{project → src/project}/generate-readme.js +6 -13
  30. package/dist/{project → src/project}/index.js +4 -12
  31. package/dist/{stack.js → src/stack.js} +2 -2
  32. package/dist/src/tools.js +39 -0
  33. package/dist/types/index.d.ts +50 -9
  34. package/dist/types/lib/app.d.ts +3 -0
  35. package/dist/types/lib/commands/build-process/boot.d.ts +8 -0
  36. package/dist/types/lib/commands/build-process/cliFactory.d.ts +32 -0
  37. package/dist/types/lib/commands/build-process/dataLayer.d.ts +7 -0
  38. package/dist/types/lib/commands/build-process/readEnv.d.ts +1 -0
  39. package/dist/types/lib/commands/build-process/runMonoCommand.d.ts +10 -0
  40. package/dist/types/lib/commands/build-process/runners/processManager.d.ts +5 -0
  41. package/dist/types/lib/commands/build-process/runners/runBackground.d.ts +2 -0
  42. package/dist/types/lib/commands/build-process/runners/runForeground.d.ts +6 -0
  43. package/dist/types/lib/commands/build-process/test.d.ts +1 -0
  44. package/dist/types/lib/commands/build-process/testflag.d.ts +1 -0
  45. package/dist/types/lib/commands/build-process/validators.d.ts +1 -0
  46. package/dist/types/lib/commands/loadFromRoot.d.ts +7 -0
  47. package/dist/types/lib/commands/prune/prune.d.ts +1 -0
  48. package/dist/types/lib/config.d.ts +2 -0
  49. package/dist/types/lib/filterUnwantedEnvVars.d.ts +2 -0
  50. package/dist/types/lib/generateNewEnvList.d.ts +1 -0
  51. package/dist/types/lib/index.d.ts +2 -0
  52. package/dist/types/src/cdk/cdk.d.ts +1 -0
  53. package/dist/types/src/cdk/index.d.ts +1 -0
  54. package/dist/types/src/expo.d.ts +4 -0
  55. package/dist/types/src/index.d.ts +15 -0
  56. package/dist/types/src/project/build-mono-readme.d.ts +1 -0
  57. package/dist/types/src/project/generate-readme.d.ts +1 -0
  58. package/dist/types/{project → src/project}/index.d.ts +1 -1
  59. package/dist/types/src/project/merge-env.d.ts +1 -0
  60. package/dist/types/src/tools.d.ts +3 -0
  61. package/lib/app.d.ts +3 -0
  62. package/lib/app.ts +58 -0
  63. package/lib/commands/build-process/boot.d.ts +8 -0
  64. package/lib/commands/build-process/boot.ts +21 -0
  65. package/lib/commands/build-process/cliFactory.d.ts +32 -0
  66. package/lib/commands/build-process/cliFactory.ts +219 -0
  67. package/lib/commands/build-process/dataLayer.d.ts +7 -0
  68. package/lib/commands/build-process/dataLayer.ts +61 -0
  69. package/lib/commands/build-process/index.d.ts +1 -0
  70. package/lib/commands/build-process/index.ts +14 -0
  71. package/lib/commands/build-process/readEnv.d.ts +1 -0
  72. package/lib/commands/build-process/readEnv.ts +37 -0
  73. package/lib/commands/build-process/runMonoCommand.d.ts +10 -0
  74. package/lib/commands/build-process/runMonoCommand.ts +96 -0
  75. package/lib/commands/build-process/runners/processManager.d.ts +5 -0
  76. package/lib/commands/build-process/runners/processManager.ts +42 -0
  77. package/lib/commands/build-process/runners/runBackground.d.ts +2 -0
  78. package/lib/commands/build-process/runners/runBackground.ts +56 -0
  79. package/lib/commands/build-process/runners/runForeground.d.ts +6 -0
  80. package/lib/commands/build-process/runners/runForeground.ts +59 -0
  81. package/lib/commands/build-process/test.d.ts +1 -0
  82. package/lib/commands/build-process/test.ts +42 -0
  83. package/lib/commands/build-process/testflag.d.ts +1 -0
  84. package/lib/commands/build-process/testflag.ts +1 -0
  85. package/lib/commands/build-process/validators.d.ts +1 -0
  86. package/lib/commands/build-process/validators.ts +16 -0
  87. package/lib/commands/loadFromRoot.d.ts +7 -0
  88. package/lib/commands/loadFromRoot.ts +51 -0
  89. package/lib/commands/prune/index.d.ts +1 -0
  90. package/lib/commands/prune/index.ts +9 -0
  91. package/lib/commands/prune/prune.d.ts +1 -0
  92. package/lib/commands/prune/prune.ts +50 -0
  93. package/lib/config.d.ts +2 -0
  94. package/lib/filterUnwantedEnvVars.d.ts +2 -0
  95. package/lib/filterUnwantedEnvVars.ts +95 -0
  96. package/lib/generateNewEnvList.d.ts +1 -0
  97. package/lib/generateNewEnvList.ts +17 -0
  98. package/lib/index.d.ts +2 -0
  99. package/lib/index.ts +59 -0
  100. package/package.json +99 -84
  101. package/src/cdk/cdk.d.ts +1 -7
  102. package/src/cdk/cdk.ts +1 -0
  103. package/src/cdk/index.d.ts +1 -0
  104. package/src/cdk/index.ts +1 -0
  105. package/src/expo-files/filterUnwantedEnvVars.d.ts +3 -0
  106. package/src/expo-files/filterUnwantedEnvVars.ts +141 -144
  107. package/src/expo.d.ts +2 -9
  108. package/src/expo.ts +116 -0
  109. package/src/index.d.ts +22 -0
  110. package/src/index.ts +39 -42
  111. package/src/loadFromRoot.d.ts +32 -0
  112. package/src/merge-env.d.ts +1 -0
  113. package/src/merge-env.ts +24 -0
  114. package/src/project/build-mono-readme.d.ts +1 -0
  115. package/src/project/build-mono-readme.ts +460 -514
  116. package/src/project/build-readme.d.ts +2 -0
  117. package/src/project/generate-docs.d.ts +11 -0
  118. package/src/project/generate-readme.d.ts +1 -0
  119. package/src/project/generate-readme.ts +259 -284
  120. package/src/project/index.d.ts +45 -0
  121. package/src/project/index.ts +134 -144
  122. package/src/project/merge-env.d.ts +1 -0
  123. package/src/stack.d.ts +21 -0
  124. package/src/stack.ts +54 -55
  125. package/src/tools.d.ts +3 -4
  126. package/src/tools.ts +48 -0
  127. package/src/types/expo-config.d.ts +49 -0
  128. package/dist/cdk/index.js +0 -55
  129. package/dist/project/merge-env.js +0 -31
  130. package/dist/tools.js +0 -35
  131. package/dist/types/cdk/index.d.ts +0 -2
  132. package/dist/types/expo.d.ts +0 -3
  133. package/dist/types/merge-env.d.ts +0 -1
  134. package/dist/types/tools.d.ts +0 -1
  135. package/lib/app.js +0 -49
  136. package/lib/commands/build-process/boot.js +0 -15
  137. package/lib/commands/build-process/cliFactory.js +0 -163
  138. package/lib/commands/build-process/dataLayer.js +0 -59
  139. package/lib/commands/build-process/index.js +0 -13
  140. package/lib/commands/build-process/readEnv.js +0 -37
  141. package/lib/commands/build-process/runMonoCommand.js +0 -102
  142. package/lib/commands/build-process/runners/processManager.js +0 -38
  143. package/lib/commands/build-process/runners/runBackground.js +0 -60
  144. package/lib/commands/build-process/runners/runForeground.js +0 -60
  145. package/lib/commands/build-process/test.js +0 -50
  146. package/lib/commands/build-process/testflag.js +0 -1
  147. package/lib/commands/build-process/validators.js +0 -17
  148. package/lib/commands/generate/generateSeed.js +0 -223
  149. package/lib/commands/generate/index.js +0 -30
  150. package/lib/commands/loadFromRoot.js +0 -55
  151. package/lib/commands/prune/index.js +0 -12
  152. package/lib/commands/prune/prune.js +0 -50
  153. package/lib/commands/seed/import.js +0 -30
  154. package/lib/commands/seed/index.js +0 -12
  155. package/lib/commands/submit/index.js +0 -38
  156. package/lib/commands/update/eas.js +0 -39
  157. package/lib/commands/update/index.js +0 -87
  158. package/lib/filterUnwantedEnvVars.js +0 -123
  159. package/lib/generateNewEnvList.js +0 -14
  160. package/lib/index.js +0 -58
  161. package/src/cdk/index.js +0 -59
  162. package/src/expo.js +0 -133
  163. package/src/merge-env.js +0 -32
  164. package/src/tools.js +0 -36
  165. package/types.d.ts +0 -83
  166. /package/dist/{expo-files → src/expo-files}/filterUnwantedEnvVars.js +0 -0
  167. /package/dist/{loadFromRoot.js → src/loadFromRoot.js} +0 -0
  168. /package/dist/{project → src/project}/build-readme.js +0 -0
  169. /package/dist/{project → src/project}/generate-docs.js +0 -0
  170. /package/dist/{merge-env.js → src/project/merge-env.js} +0 -0
  171. /package/dist/types/{project/build-mono-readme.d.ts → lib/commands/build-process/index.d.ts} +0 -0
  172. /package/dist/types/{project/generate-readme.d.ts → lib/commands/prune/index.d.ts} +0 -0
  173. /package/dist/types/{expo-files → src/expo-files}/filterUnwantedEnvVars.d.ts +0 -0
  174. /package/dist/types/{loadFromRoot.d.ts → src/loadFromRoot.d.ts} +0 -0
  175. /package/dist/types/{project → src}/merge-env.d.ts +0 -0
  176. /package/dist/types/{project → src/project}/build-readme.d.ts +0 -0
  177. /package/dist/types/{project → src/project}/generate-docs.d.ts +0 -0
  178. /package/dist/types/{stack.d.ts → src/stack.d.ts} +0 -0
  179. /package/lib/{config.js → config.ts} +0 -0
@@ -1,60 +0,0 @@
1
- import { spawn } from 'child_process';
2
- import { replaceTokens, setData } from '../dataLayer.js';
3
- import { filterUnwantedEnvVars } from '../../../../lib/filterUnwantedEnvVars.js';
4
- import os from 'node:os';
5
- import path from 'node:path';
6
- const homeBin = path.join(os.homedir(), 'bin');
7
- const PATH = [homeBin, process.env.PATH].filter(Boolean).join(path.delimiter);
8
- // Regex to capture tokens like: {out:field value}
9
- const TOKEN_RX = /\{out:(?<field>[^\s}]+)\s+(?<value>[^\s}]+)\}/g;
10
-
11
- /**
12
- * Run a command in the foreground, capturing stdout/stderr. Extracts token patterns
13
- * of the form {out:field value} and stores them in the shared dataLayer.
14
- */
15
-
16
- export function runForeground(cmd, envObj = {}, options = {}) {
17
- const filteredEnv = filterUnwantedEnvVars(process.env);
18
- const newEnv = { ...filteredEnv, ...envObj };
19
- const newCmd = replaceTokens(cmd, newEnv);
20
-
21
- return new Promise((resolve, reject) => {
22
- let lastLine = '';
23
- let buffer = '';
24
-
25
- const child = spawn(newCmd, {
26
- shell: true,
27
- env: { ...newEnv, PATH },
28
- //env: { ...newEnv },
29
- stdio: ['inherit', 'pipe', 'pipe'],
30
- });
31
-
32
- const handleData = (chunk) => {
33
- const text = chunk.toString();
34
- buffer += text;
35
- const lines = text.trim().split(/\r?\n/);
36
- if (lines.length) lastLine = lines[lines.length - 1];
37
- process.stdout.write(text); // echo output
38
- };
39
-
40
- child.stdout.on('data', handleData);
41
- child.stderr.on('data', handleData);
42
- child.on('error', reject);
43
-
44
- child.on('exit', (code, signal) => {
45
- // Extract tokens and populate dataLayer
46
- for (const match of buffer.matchAll(TOKEN_RX)) {
47
- setData(match.groups.field, match.groups.value);
48
- }
49
-
50
- if (signal)
51
- return reject(new Error(`${cmd} exited via signal ${signal}`));
52
- if (code === 0) return resolve(lastLine);
53
- reject(
54
- new Error(`${cmd} exited with code ${code}. Last line: ${lastLine}`)
55
- );
56
- });
57
- });
58
- }
59
-
60
- export default runForeground;
@@ -1,50 +0,0 @@
1
- import { execSync } from 'child_process';
2
- import { getRootJson, getMonoConfig } from '../loadFromRoot.js';
3
-
4
- //Run Action List before all script actions
5
-
6
- const WorkSpaceDirectory = '${dir}';
7
-
8
- export function executeCommandsIfWorkspaceAction(
9
- action,
10
- commands = [],
11
- fullEnv
12
- ) {
13
- const { config } = getMonoConfig();
14
- const workspacemap = config.workspace?.packageMaps || {};
15
-
16
- const result = execSync('yarn workspaces list --json', { encoding: 'utf8' })
17
- .trim()
18
- .split('\n')
19
- .map((line) => JSON.parse(line))
20
- .filter((obj) => obj !== '.');
21
-
22
- const workspaces = result.map((w) => w.name);
23
-
24
- const actualAction =
25
- workspacemap ? workspacemap[action[1]] || action[1] : action[1];
26
-
27
- const rootJson = getRootJson();
28
- const workspacesList = (rootJson.workspaces || []).map((item) =>
29
- item.replace(/[\.\/\*]/g, '')
30
- );
31
-
32
- const filteredResult =
33
- result.filter((obj) => obj.name === actualAction)[0] || {};
34
-
35
- const workingDirectory = filteredResult.location || '';
36
- // Check if the action is a workspace action
37
- if (action) {
38
- // Execute each command in the context of the workspace
39
- commands.forEach((cmd) => {
40
- const finalCommand = cmd.replace(WorkSpaceDirectory, workingDirectory);
41
-
42
- // Here you would add the logic to execute the command
43
- execSync(finalCommand, {
44
- stdio: 'inherit',
45
- shell: true,
46
- env: { ...fullEnv },
47
- });
48
- });
49
- }
50
- }
@@ -1 +0,0 @@
1
- export const testFlag = true;
@@ -1,17 +0,0 @@
1
- // Option/value validation utilities
2
- export function verifyOptionValue(optionKey, value, optionsData) {
3
- const optionInfo = optionsData[optionKey];
4
- if (optionInfo && Array.isArray(optionInfo.options)) {
5
- let actualOptions = optionInfo.options;
6
- if (actualOptions) {
7
- actualOptions =
8
- optionInfo?.allowAll ? [...actualOptions, 'all'] : [...actualOptions];
9
- }
10
- if (!actualOptions.includes(value)) {
11
- throw new Error(
12
- `Invalid value for --${optionKey}: ${value}. Valid options are: ${actualOptions.join(', ')}`
13
- );
14
- }
15
- }
16
- return value;
17
- }
@@ -1,223 +0,0 @@
1
- import fs from 'fs';
2
- // Initialize the DynamoDB client
3
-
4
- import { readFileSync } from 'fs';
5
- import path from 'path';
6
-
7
- import { DynamoDBClient, ScanCommand } from '@aws-sdk/client-dynamodb';
8
- import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
9
-
10
- import { join } from 'node:path';
11
- const packageJSON = JSON.parse(
12
- readFileSync(join(process.cwd(), 'package.json'), 'utf8')
13
- );
14
-
15
- const awsObject = packageJSON['aws'] || {};
16
- const projectName = packageJSON['name'] || 'project';
17
-
18
- const awsProfile = awsObject['profile'] || 'default';
19
-
20
- // TODO: Fix Copy Issues
21
- const dirPath = './docker/seed'; // Folder path to delete files from
22
-
23
- // Function to delete all files in the specified directory (ignores directories)
24
- function deleteFilesInDir(dir) {
25
- // Read all files and directories inside the directory
26
- const files = fs.readdirSync(dir);
27
-
28
- // Loop through each file and directory
29
- files.forEach((file) => {
30
- const filePath = path.join(dir, file); // Get full path of the file or directory
31
-
32
- // Check if it's a file (not a directory)
33
- const stats = fs.statSync(filePath);
34
-
35
- if (stats.isFile()) {
36
- // If it's a file, delete it
37
- fs.unlinkSync(filePath);
38
- }
39
- });
40
- }
41
-
42
- // Function to scan the DynamoDB table and generate the desired JSON format
43
- async function generateTableExport(tablename, client, profilesOnly = false) {
44
- let params = {
45
- TableName: tablename,
46
- };
47
-
48
- // This will hold all the data retrieved from DynamoDB
49
- let allItems = [];
50
- let lastEvaluatedKey = null;
51
-
52
- // If there are more items (pagination in case of large tables)
53
- do {
54
- if (lastEvaluatedKey) {
55
- params.ExclusiveStartKey = lastEvaluatedKey;
56
- }
57
-
58
- try {
59
- // Perform the scan operation
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
64
- } catch (error) {
65
- console.error('Error scanning DynamoDB table:', error);
66
- return;
67
- }
68
- } while (lastEvaluatedKey); // Continue scanning if there are more pages of results
69
-
70
- // Format the data into the desired JSON structure
71
- //
72
- const formattedData = {
73
- [tablename]: allItems
74
- .filter(
75
- (item) =>
76
- !profilesOnly ||
77
- !tablename.includes('Database') ||
78
- unmarshall(item)['SK'].includes('PROFILE')
79
- )
80
- .map((item) => {
81
- const formattedItem = unmarshall(item); // Unmarshall DynamoDB format to JS object
82
- // Ensure the correct format: PutRequest -> Item
83
- //if (tablename.includes('Database') && !formattedItem['SK'].includes('USER')) return undefined;
84
- return {
85
- PutRequest: {
86
- Item: marshall(formattedItem), // Marshall JS object back to DynamoDB format
87
- },
88
- };
89
- }),
90
- };
91
- return formattedData;
92
- }
93
- async function exportDynamoTable(
94
- tables,
95
- client,
96
- dbRewrites,
97
- profilesOnly = false,
98
- strOut = './docker/seed'
99
- ) {
100
- deleteFilesInDir(dirPath);
101
- let output = await Promise.all(
102
- tables.map(
103
- async (tableName) =>
104
- await generateTableExport(tableName, client, profilesOnly)
105
- )
106
- );
107
- const fileName = `${strOut}/dynamodb-seed`;
108
-
109
- const outputRes = {};
110
- output.map((item) => {
111
- const keys = Object.keys(item);
112
-
113
- return keys.map((key) => {
114
- const value = item[key].filter((item) => item !== undefined);
115
- outputRes[key] = value;
116
- return { value };
117
- });
118
- });
119
-
120
- output = outputRes;
121
-
122
- const fileObject = {};
123
- const dbObject = {};
124
- Object.keys(output).forEach((key) => {
125
- const value = output[key];
126
-
127
- if (value.length > 0) {
128
- const dbKey = dbRewrites[key] || key;
129
-
130
- dbObject[dbKey] = value;
131
- }
132
- });
133
-
134
- let countTotal = 0;
135
-
136
- Object.keys(dbObject).forEach((key) => {
137
- let currentPosition = 0;
138
- const numOfItems = 20;
139
- const putItems = dbObject[key];
140
- while (currentPosition < putItems.length) {
141
- if (dbObject[key].length > numOfItems) {
142
- const result = putItems.slice(
143
- currentPosition,
144
- currentPosition + numOfItems
145
- );
146
- fileObject[`${fileName}-${countTotal}`] = { [key]: result };
147
- currentPosition += numOfItems;
148
- countTotal += 1;
149
- } else {
150
- const result = putItems.slice(currentPosition, putItems.length);
151
- fileObject[`${fileName}-${countTotal}`] = { [key]: result };
152
- currentPosition += numOfItems;
153
- countTotal += 1;
154
- }
155
- }
156
- });
157
-
158
- Object.keys(fileObject).forEach((key) => {
159
- fs.writeFileSync(`${key}.json`, JSON.stringify(fileObject[key], null, 2));
160
- });
161
- }
162
- export function createDirIfNotExists(dirname) {
163
- if (!fs.existsSync(dirname)) {
164
- fs.mkdirSync(dirname);
165
- }
166
- }
167
-
168
- // Run the function
169
-
170
- export function exportTable(
171
- newTables,
172
- owner,
173
- altOwner = 'dev',
174
- rewriteDb,
175
- live = false,
176
- region = 'us-east-2',
177
- profilesOnly = false
178
- ) {
179
- createDirIfNotExists(dirPath);
180
- const tables = live ? ['MainDatabase'] : ['MainDB'];
181
- const dbRewrites = {};
182
- const dbOg = {};
183
- tables.map((table, index) => (dbOg[table] = newTables[index] || ''));
184
- tables.map((table, index) => {
185
- const rewriteDbIndex = rewriteDb[index];
186
- if (rewriteDbIndex === 'MainDB') {
187
- dbRewrites[`${projectName}-infra-${table}-${owner}`] =
188
- `${rewriteDbIndex || table}`;
189
- } else {
190
- const newTable = tables[index].replace(
191
- tables[index],
192
- newTables[index] || tables[index]
193
- );
194
- dbRewrites[`${projectName}-infra-${table}-${owner}`] =
195
- `${projectName}-infra-${newTable || table}-${altOwner || owner}`;
196
- }
197
- });
198
-
199
- let dbTables = ['MainDB'];
200
-
201
- if (live) {
202
- dbTables = tables.map((table) => {
203
- return `${projectName}-infra-${table}-${owner}`;
204
- });
205
- }
206
-
207
- let client = undefined;
208
- if (live) {
209
- client = new DynamoDBClient({
210
- region: region, // Replace with your AWS region
211
- });
212
- } else {
213
- client = new DynamoDBClient({
214
- region: region, // Replace with your AWS region
215
- endpoint: 'http://localhost:8000', // The default local DynamoDB endpoint
216
- credentials: {
217
- accessKeyId: 'fakeAccessKeyId', // Use fake credentials for local DynamoDB
218
- secretAccessKey: 'fakeSecretAccessKey',
219
- },
220
- });
221
- }
222
- exportDynamoTable(dbTables, client, dbRewrites, profilesOnly);
223
- }
@@ -1,30 +0,0 @@
1
- import { program } from '../../app.js'
2
- import { exportTable } from './generateSeed.js'
3
-
4
- program
5
- .command('generate')
6
- .description('Generate seed data in ./docker/seed')
7
- .argument('[<string>]', 'Tables to generateFrom')
8
- .option('-o, --owner <owner>', 'Owner of the tables')
9
- .option('-n, --newowner <newowner>', 'New owner of the tables')
10
- .option('-p, --live', 'Pull from live')
11
- .option('-r, --region <region>', 'Region to deploy to')
12
- .option('-d, --db <db>', 'Databases to rewrite to')
13
- .option('--profiles', 'Profiles only seed generation')
14
- .action(async (str, options) => {
15
- const owner = options.owner || 'dev'
16
- const profilesOnly = options.profiles || false
17
- const tables = (str || '').split(',')
18
- let nameRedirect = []
19
- if (options.db) nameRedirect = options.db.split(',')
20
-
21
- exportTable(
22
- tables,
23
- owner,
24
- options.newowner,
25
- nameRedirect,
26
- options.live,
27
- options.region,
28
- profilesOnly,
29
- )
30
- })
@@ -1,55 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- export function getRootDirectory() {
5
- return path.join(process.cwd());
6
- }
7
-
8
- export function getRootJson() {
9
- const jsonPath = path.join(process.cwd(), 'package.json'); // cwd + file
10
- const raw = fs.readFileSync(jsonPath, 'utf-8');
11
- const data = JSON.parse(raw);
12
-
13
- return data;
14
- }
15
-
16
- export function getMonoFiles() {
17
- const dir = path.join(process.cwd(), '.mono');
18
-
19
- if (!fs.existsSync(dir)) {
20
- return [];
21
- }
22
-
23
- const files = fs.readdirSync(dir); // names only
24
- return files.map((f) => path.join(dir, f));
25
- }
26
-
27
- const disallowedFiles = ['tools'];
28
-
29
- export function getMonoConfig() {
30
- const objMono = getMonoFiles();
31
- const monoFileConfig = {};
32
- let configObject = {};
33
- for (const file of objMono) {
34
- const fileName = path.basename(file).replace('.json', '');
35
- if (disallowedFiles.includes(fileName))
36
- throw new Error(`Disallowed file name in .mono directory: ${fileName}`);
37
- if (fileName === 'config') {
38
- const raw = fs.readFileSync(file, 'utf-8');
39
- const data = JSON.parse(raw);
40
- if (data) configObject = data;
41
- } else {
42
- const raw = fs.readFileSync(file, 'utf-8');
43
- const data = JSON.parse(raw);
44
- monoFileConfig[fileName] = data;
45
- }
46
- }
47
-
48
- return {
49
- files: monoFileConfig,
50
- // config: {
51
- // workspace: workspaceMap,
52
- // },
53
- config: configObject,
54
- };
55
- }
@@ -1,12 +0,0 @@
1
- import { spawn } from 'child_process';
2
-
3
- import { program } from '../../app.js';
4
- import { pruneRepo } from './prune.js';
5
-
6
- program
7
- .command('prune2')
8
- .description('Prune local branches that are not on origin')
9
-
10
- .action(() => {
11
- pruneRepo();
12
- });
@@ -1,50 +0,0 @@
1
- import { execSync } from 'child_process';
2
-
3
- const log = (...args) => console.log(...args);
4
- const err = (...args) => console.error(...args);
5
- export function pruneRepo() {
6
- try {
7
- // Fetch and prune remote branches
8
- log('Fetching latest branch data from origin...');
9
- execSync('git fetch --prune', { stdio: 'inherit' });
10
-
11
- // Get local branches (trim whitespace)
12
- const localBranches = execSync("git branch --format '%(refname:short)'")
13
- .toString()
14
- .trim()
15
- .split('\n')
16
- .map((branch) => branch.trim().replaceAll("'", ''));
17
-
18
- // Get remote branches (remove "origin/" prefix)
19
- const remoteBranches = execSync('git branch -r')
20
- .toString()
21
- .trim()
22
- .split('\n')
23
- .map((branch) => branch.replace(/^\s*origin\//, '').trim());
24
-
25
- // Find local branches that are NOT in remote branches
26
- const branchesToDelete = localBranches.filter(
27
- (branch) => !remoteBranches.includes(branch)
28
- );
29
- if (branchesToDelete.length === 0) {
30
- log('No local branches to delete.');
31
- process.exit(0);
32
- }
33
-
34
- // Delete untracked local branches
35
- log('Deleting local branches that are not on origin...');
36
- branchesToDelete.forEach((branch) => {
37
- log(`Attempting to delete: ${branch}`);
38
- try {
39
- execSync(`git branch -D ${branch}`, { stdio: 'inherit' });
40
- log(`Deleted: ${branch}`);
41
- } catch (error) {
42
- error(`Failed to delete branch ${branch}:`, error.message);
43
- }
44
- });
45
-
46
- log('Cleanup complete!');
47
- } catch (error) {
48
- err('An error occurred:', error.message);
49
- }
50
- }
@@ -1,30 +0,0 @@
1
- import { execSync } from 'child_process';
2
- import fs from 'fs';
3
- import path from 'path';
4
-
5
- export function importAllDynamoBatches(folderPath, useRemote = false) {
6
- const files = fs
7
- .readdirSync(folderPath)
8
- .filter(
9
- (file) => file.startsWith('dynamodb-seed-') && file.endsWith('.json')
10
- );
11
-
12
- files.sort(); // Optional: ensures files run in order
13
-
14
- for (const file of files) {
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}`;
21
- try {
22
- execSync(baseCommand, {
23
- stdio: 'inherit',
24
- });
25
- } catch (err) {
26
- console.error(`❌ Error with ${file}:`, err.message);
27
- break; // or continue if you want to skip failed files
28
- }
29
- }
30
- }
@@ -1,12 +0,0 @@
1
- import { spawn } from 'child_process'
2
-
3
- import { program } from '../../app.js'
4
- import { importAllDynamoBatches } from './import.js'
5
-
6
- program
7
- .command('seed')
8
- .description('Execute eas build command')
9
- .option('-p, --live', 'Pull from live')
10
- .action(async (options) => {
11
- importAllDynamoBatches('./docker/seed', options.live)
12
- })
@@ -1,38 +0,0 @@
1
- import { spawn } from 'child_process';
2
-
3
- import { program } from '../../app.js';
4
- import { generateEnvValues } from '../../app.js';
5
- import { STAGING_URL } from '../../config.js';
6
- import os from 'node:os';
7
- import path from 'node:path';
8
- const homeBin = path.join(os.homedir(), 'bin');
9
- const PATH = [homeBin, process.env.PATH].filter(Boolean).join(path.delimiter);
10
- program
11
- .command('submit')
12
- .description('Execute eas build command')
13
- .option('--android', 'Build to target preview profile')
14
- .option('--ios', 'Build to target production profile')
15
- .action((str, options) => {
16
- //
17
-
18
- let envObj = generateEnvValues(true, '', false);
19
-
20
- envObj.NEXT_PUBLIC_API_URL = `${STAGING_URL}`;
21
- envObj.NEXT_FORCE_PROD = 'true';
22
- envObj.EAS_BUILD_PROFILE = 'production';
23
-
24
- const command = `workspace app eas submit ${str.android ? `--platform android` : `--platform ios`}`;
25
-
26
- const child = spawn('yarn', [command], {
27
- stdio: 'inherit',
28
- shell: true, // required if using shell-style commands or cross-platform support
29
- env: {
30
- ...envObj,
31
- PATH,
32
- },
33
- });
34
-
35
- child.on('exit', (code) => {
36
- process.exit(code ?? 0);
37
- });
38
- });
@@ -1,39 +0,0 @@
1
- import { execSync } from 'child_process'
2
-
3
- export function getEASChannels() {
4
- const channelsData = execSync(
5
- 'yarn eas channel:list --non-interactive --json',
6
- { stdio: ['pipe', 'pipe', 'ignore'] }, // Ignore stderr
7
- ).toString()
8
-
9
- // Extract valid JSON from any extra noise
10
- const jsonStart = channelsData.indexOf('[')
11
- const jsonEnd = channelsData.lastIndexOf(']') + 1
12
-
13
- if (jsonStart === -1 || jsonEnd === -1) {
14
- throw new Error('JSON output not found in command output')
15
- }
16
-
17
- const jsonSlice = channelsData.slice(jsonStart, jsonEnd)
18
- const channels = JSON.parse(jsonSlice)
19
- return channels
20
- }
21
-
22
- export function getEASBranches() {
23
- const channelsData = execSync(
24
- 'yarn eas branch:list --non-interactive --json',
25
- { stdio: ['pipe', 'pipe', 'ignore'] }, // Ignore stderr
26
- ).toString()
27
-
28
- // Extract valid JSON from any extra noise
29
- const jsonStart = channelsData.indexOf('[')
30
- const jsonEnd = channelsData.lastIndexOf(']') + 1
31
-
32
- if (jsonStart === -1 || jsonEnd === -1) {
33
- throw new Error('JSON output not found in command output')
34
- }
35
-
36
- const jsonSlice = channelsData.slice(jsonStart, jsonEnd)
37
- const channels = JSON.parse(jsonSlice)
38
- return channels
39
- }