@snap/valdi 1.0.6 → 1.0.8

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 (161) hide show
  1. package/README.md +22 -10
  2. package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
  3. package/bundled-skills/registry.json +20 -0
  4. package/bundled-skills/skills/valdi-android/skill.md +89 -0
  5. package/bundled-skills/skills/valdi-async/skill.md +246 -0
  6. package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
  7. package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
  8. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
  9. package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
  10. package/bundled-skills/skills/valdi-bazel/skill.md +122 -0
  11. package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
  12. package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
  13. package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
  14. package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
  15. package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
  16. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
  17. package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
  18. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
  19. package/bundled-skills/skills/valdi-custom-view/skill.md +62 -0
  20. package/bundled-skills/skills/valdi-ios/skill.md +93 -0
  21. package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
  22. package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
  23. package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
  24. package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
  25. package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
  26. package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
  27. package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
  28. package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
  29. package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
  30. package/{.metadata/.cursorrules.template → bundled-skills/skills/valdi-overview/skill.md} +23 -13
  31. package/bundled-skills/skills/valdi-perf/skill.md +197 -0
  32. package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
  33. package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
  34. package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
  35. package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
  36. package/bundled-skills/skills/valdi-polyglot-module/skill.md +85 -0
  37. package/bundled-skills/skills/valdi-setup/skill.md +129 -0
  38. package/bundled-skills/skills/valdi-testing/skill.md +65 -0
  39. package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
  40. package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
  41. package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
  42. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
  43. package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
  44. package/dist/commands/bootstrap.js +3 -9
  45. package/dist/commands/newModule.js +10 -14
  46. package/dist/commands/skills.js +16 -0
  47. package/dist/commands/skills_commands/create.js +125 -0
  48. package/dist/commands/skills_commands/install.js +96 -0
  49. package/dist/commands/skills_commands/list.js +83 -0
  50. package/dist/commands/skills_commands/remove.js +41 -0
  51. package/dist/commands/skills_commands/update.js +59 -0
  52. package/dist/core/constants.js +1 -1
  53. package/dist/index.js +5 -0
  54. package/dist/setup/versions.js +1 -1
  55. package/dist/utils/skillsAdapters.js +140 -0
  56. package/dist/utils/skillsRegistry.js +40 -0
  57. package/package.json +6 -1
  58. package/.bazelignore +0 -2
  59. package/.bootstrap/apps/cli_application/AGENTS.md.template +0 -291
  60. package/.bootstrap/apps/cli_application/BUILD.bazel.template +0 -7
  61. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -11
  62. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/src/index.ts +0 -1
  63. package/.bootstrap/apps/ui_application/.eslint.rc +0 -27
  64. package/.bootstrap/apps/ui_application/AGENTS.md.template +0 -278
  65. package/.bootstrap/apps/ui_application/BUILD.bazel.template +0 -19
  66. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -21
  67. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/res/valdi@3x.png +0 -0
  68. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/src/App.tsx +0 -133
  69. package/.bootstrap/apps/ui_application/package.json +0 -24
  70. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
  71. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
  72. package/.bootstrap/modules/cpp_bridge_module/src/Calculator.d.ts +0 -4
  73. package/.bootstrap/modules/ios_android_bridge_module/BUILD.bazel.template +0 -39
  74. package/.bootstrap/modules/ios_android_bridge_module/android/CalculatorModuleFactory.kt.template +0 -18
  75. package/.bootstrap/modules/ios_android_bridge_module/ios/SCCCalculatorModuleFactory.m.template +0 -31
  76. package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
  77. package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
  78. package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
  79. package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
  80. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
  81. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
  82. package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
  83. package/.bootstrap/modules/ui_component/BUILD.bazel.template +0 -34
  84. package/.bootstrap/modules/ui_component/src/NewModuleComponent.tsx +0 -45
  85. package/.config/copyconfig.json +0 -10
  86. package/.editorconfig +0 -21
  87. package/.eslintignore +0 -1
  88. package/.eslintrc.js +0 -72
  89. package/.github/README.md +0 -164
  90. package/.metadata/.bazelrc.template +0 -91
  91. package/.metadata/.bazelversion.template +0 -1
  92. package/.metadata/.editorconfig.template +0 -37
  93. package/.metadata/.eslintrc.js.template +0 -27
  94. package/.metadata/.gitignore.template +0 -4
  95. package/.metadata/.prettierrc.json.template +0 -7
  96. package/.metadata/.watchmanconfig.template +0 -8
  97. package/.metadata/README.md.template +0 -31
  98. package/.metadata/WORKSPACE.template +0 -57
  99. package/.metadata/config.yaml.template +0 -1
  100. package/.metadata/package.json.template +0 -23
  101. package/.prettierignore +0 -2
  102. package/.prettierrc.json +0 -7
  103. package/LINUX_COMPATIBILITY.md +0 -248
  104. package/prettier.config.js +0 -4
  105. package/scripts/sync-agents-md.sh +0 -44
  106. package/scripts/update-agents-templates.ts +0 -170
  107. package/spec/support/jasmine.json +0 -6
  108. package/src/commands/bootstrap.ts +0 -409
  109. package/src/commands/build.ts +0 -89
  110. package/src/commands/devSetup.ts +0 -17
  111. package/src/commands/doctor.ts +0 -1832
  112. package/src/commands/export.ts +0 -131
  113. package/src/commands/hotreload.ts +0 -108
  114. package/src/commands/install.ts +0 -93
  115. package/src/commands/lint.ts +0 -15
  116. package/src/commands/lint_commands/lintCheck.ts +0 -53
  117. package/src/commands/lint_commands/lintFormat.ts +0 -49
  118. package/src/commands/log.ts +0 -108
  119. package/src/commands/newModule.ts +0 -286
  120. package/src/commands/package.ts +0 -102
  121. package/src/commands/projectsync.ts +0 -488
  122. package/src/commands/test.ts +0 -68
  123. package/src/core/constants.ts +0 -97
  124. package/src/core/errors.ts +0 -10
  125. package/src/index.ts +0 -22
  126. package/src/setup/DevSetupHelper.ts +0 -290
  127. package/src/setup/linuxSetup.ts +0 -261
  128. package/src/setup/macOSSetup.ts +0 -156
  129. package/src/setup/setupEntryPoint.ts +0 -64
  130. package/src/setup/versions.ts +0 -8
  131. package/src/utils/ArgumentsResolver.ts +0 -23
  132. package/src/utils/BazelClient.ts +0 -285
  133. package/src/utils/Digraph.ts +0 -81
  134. package/src/utils/LoadingIndicator.ts +0 -43
  135. package/src/utils/applicationUtils.ts +0 -276
  136. package/src/utils/buildInfo.ts +0 -99
  137. package/src/utils/byString.ts +0 -3
  138. package/src/utils/cliUtils.ts +0 -112
  139. package/src/utils/copyBootstrapFiles.ts +0 -30
  140. package/src/utils/deviceUtils.ts +0 -76
  141. package/src/utils/errorUtils.ts +0 -63
  142. package/src/utils/fileUtils.ts +0 -257
  143. package/src/utils/githubUtils.ts +0 -102
  144. package/src/utils/jsonUtils.ts +0 -30
  145. package/src/utils/lintUtils.ts +0 -190
  146. package/src/utils/linuxDistro.spec.ts +0 -219
  147. package/src/utils/linuxDistro.ts +0 -326
  148. package/src/utils/logUtils.ts +0 -9
  149. package/src/utils/pathUtils.ts +0 -12
  150. package/src/utils/stringUtils.spec.ts +0 -95
  151. package/src/utils/stringUtils.ts +0 -103
  152. package/src/utils/tempDir.ts +0 -24
  153. package/src/utils/zipUtils.ts +0 -14
  154. package/test/ValdiSmokeTest.ts +0 -279
  155. package/test/helpers/AsyncHelpers.ts +0 -113
  156. package/test/helpers/CommandHelpers.ts +0 -37
  157. package/test/helpers/ProjectHelpers.ts +0 -153
  158. package/test/helpers/StreamHelpers.ts +0 -37
  159. package/test/helpers/TypeScriptClient.ts +0 -217
  160. package/tsconfig.dist.json +0 -8
  161. package/tsconfig.json +0 -42
@@ -1,286 +0,0 @@
1
- import fs from 'fs';
2
- import inquirer from 'inquirer';
3
- import path from 'path';
4
- import type { Argv } from 'yargs';
5
- import { ANSI_COLORS, BOOTSTRAP_DIR_PATH } from '../core/constants';
6
- import { CliError } from '../core/errors';
7
- import type { ArgumentsResolver } from '../utils/ArgumentsResolver';
8
- import { BazelClient } from '../utils/BazelClient';
9
- import type { CliChoice } from '../utils/cliUtils';
10
- import { getUserChoice } from '../utils/cliUtils';
11
- import { copyBootstrapFiles } from '../utils/copyBootstrapFiles';
12
- import { makeCommandHandler } from '../utils/errorUtils';
13
- import type { Replacements } from '../utils/fileUtils';
14
- import { fileExists } from '../utils/fileUtils';
15
- import { wrapInColor } from '../utils/logUtils';
16
- import { toPascalCase, toSnakeCase, sanitizeProjectName, validateProjectName } from '../utils/stringUtils';
17
-
18
- const referenceString = `
19
- ******************************************
20
- Valdi Module Creation Guide
21
- ******************************************
22
-
23
- Requirements for Valdi module names:
24
- - May contain: A-Z, a-z, 0-9, '-', '_', '.'
25
- - Must start with a letter.
26
-
27
- Recommended Directory Structure:
28
- my_application/ # Root directory of your application
29
- ├── WORKSPACE # Bazel Workspace
30
- ├── BUILD.bazel # Bazel build
31
- └── modules/
32
- ├── module_a/
33
- │ ├── BUILD.bazel
34
- │ ├── android/ # Native Android sources
35
- │ ├── ios/ # Native iOS sources
36
- │ ├── cpp/ # Native C++ sources
37
- │ └── src/ # Valdi sources
38
- │ └── ModuleAComponent.tsx
39
- ├── module_b/
40
- ├── BUILD.bazel
41
- │ ├── res/ # Image and font resources
42
- │ ├── strings/ # Localizable strings
43
- └── src/
44
- └── ModuleBComponent.tsx
45
-
46
- For more comprehensive details, refer to the core-module documentation:
47
- https://github.com/Snapchat/Valdi/blob/main/docs/docs/core-module.md
48
-
49
- ******************************************
50
- `;
51
-
52
- const ALL_MODULE_TEMPLATES: readonly ModuleTemplate[] = [
53
- {
54
- name: 'UI Component',
55
- path: 'ui_component',
56
- description: `Exports a Valdi component, which can render UI elements`,
57
- },
58
- {
59
- name: 'iOS/Android Bridge module',
60
- path: 'ios_android_bridge_module',
61
- description: `Bridge module with a TypeScript API backed by Objective-C and Kotlin implementation`,
62
- },
63
- {
64
- name: 'C++ Bridge module',
65
- path: 'cpp_bridge_module',
66
- description: `Bridge module with a TypeScript API backed by a cross-platform C++ implementation`,
67
- },
68
- {
69
- name: 'iOS/Android View module',
70
- path: 'ios_android_view_module',
71
- description: `iOS and Android view exported to TypeScript, rendered through a Valdi component`,
72
- },
73
- ];
74
-
75
- interface CommandParameters {
76
- debug: boolean;
77
- skipChecks: boolean;
78
- moduleName: string;
79
- template?: string
80
- }
81
-
82
- interface Checks {
83
- confirmBazelWorkspace?: boolean;
84
- confirmValdiPath?: boolean;
85
- valdiModulePath?: string;
86
- }
87
-
88
- interface ModuleTemplate {
89
- name: string;
90
- path: string;
91
- description: string;
92
- }
93
-
94
- async function promptChecks(): Promise<Checks> {
95
- let answers: Checks = {};
96
-
97
- /**
98
- * Verify Bazel Workspace
99
- */
100
- const bazelWorkspacePath = await getBazelWorkspaceRoot();
101
-
102
- answers = await inquirer.prompt<Checks>(
103
- [
104
- {
105
- type: 'confirm',
106
- name: 'confirmBazelWorkspace',
107
- message: 'Bazel WORKSPACE not found (did you run `valdi bootstrap` first?). Continue anyway?',
108
- default: true,
109
- when() {
110
- return !bazelWorkspacePath;
111
- },
112
- },
113
- ],
114
- answers,
115
- );
116
-
117
- if (!bazelWorkspacePath && !answers.confirmBazelWorkspace) {
118
- throw new CliError('Aborting.');
119
- }
120
-
121
- /**
122
- * Verify directory structure
123
- */
124
- answers = await inquirer.prompt<Checks>(
125
- {
126
- type: 'confirm',
127
- name: 'confirmValdiPath',
128
- message:
129
- '/modules directory not found (did you run `valdi bootstrap` first?). Create module in current directory?',
130
- default: true,
131
- when(answers) {
132
- const curDir = process.cwd();
133
- const parsedPath = path.parse(curDir);
134
- if (parsedPath.base === 'modules') {
135
- // Create the new module in the current directory
136
- answers.valdiModulePath = curDir;
137
- } else if (curDir === bazelWorkspacePath) {
138
- // Create the new module in ./modules
139
- const valdiPath = path.join(curDir, 'modules');
140
- if (fs.existsSync(valdiPath)) {
141
- answers.valdiModulePath = valdiPath;
142
- }
143
- }
144
-
145
- return !answers.valdiModulePath;
146
- },
147
- },
148
- answers,
149
- );
150
-
151
- if (!answers.valdiModulePath && !answers.confirmValdiPath) {
152
- throw new CliError('Aborting.');
153
- }
154
-
155
- return answers;
156
- }
157
-
158
- async function getModuleName(argv: ArgumentsResolver<CommandParameters>): Promise<string> {
159
- return argv.getArgumentOrResolve('moduleName', async () => {
160
- const result = await inquirer.prompt<{ moduleName?: string }>(
161
- [
162
- {
163
- type: 'input',
164
- name: 'moduleName',
165
- message: 'Please provide a name for this module:',
166
- validate: (input: string) => {
167
- const validationError = validateProjectName(input);
168
- if (validationError) {
169
- return validationError;
170
- }
171
-
172
- const sanitized = sanitizeProjectName(input);
173
- const destPath = path.join(process.cwd(), sanitized);
174
- if (fileExists(destPath)) {
175
- return `Path ${destPath} already exists. Choose a different name or delete the folder and try again.`;
176
- }
177
-
178
- return true;
179
- },
180
- },
181
- ],
182
- {},
183
- );
184
-
185
- return sanitizeProjectName(result.moduleName ?? '');
186
- });
187
- }
188
-
189
- async function finalConfirmation(destPath: string, argv: ArgumentsResolver<CommandParameters>): Promise<boolean> {
190
- return argv.getArgumentOrResolve('skipChecks', async () => {
191
- const confirmMessage = `
192
- Create module?
193
- Path: ${wrapInColor(destPath, ANSI_COLORS.GREEN_COLOR)}
194
- `;
195
- const answers = await inquirer.prompt<{ confirm?: boolean }>(
196
- [
197
- {
198
- type: 'confirm',
199
- name: 'confirm',
200
- message: confirmMessage,
201
- default: true,
202
- },
203
- ],
204
- {},
205
- );
206
-
207
- return answers.confirm ?? false;
208
- });
209
- }
210
-
211
- function getBazelWorkspaceRoot() {
212
- return new BazelClient().getWorkspaceRoot();
213
- }
214
-
215
- async function valdiNewModule(argv: ArgumentsResolver<CommandParameters>) {
216
- console.log(referenceString);
217
- const skipChecks = argv.getArgument('skipChecks');
218
-
219
- const checks: Checks = skipChecks ? {} : await promptChecks();
220
- const valdiModulePath = checks.valdiModulePath ?? path.join(await getBazelWorkspaceRoot(), 'modules');
221
-
222
- let moduleName = await getModuleName(argv);
223
-
224
- // Validate module name if provided via command line argument
225
- if (argv.getArgument('moduleName')) {
226
- const validationError = validateProjectName(moduleName);
227
- if (validationError) {
228
- throw new CliError(validationError);
229
- }
230
- moduleName = sanitizeProjectName(moduleName);
231
- }
232
-
233
- const destPath = path.join(valdiModulePath, moduleName);
234
- const didConfirm = skipChecks || (await finalConfirmation(destPath, argv));
235
- if (!didConfirm) {
236
- throw new CliError('Cancelled new module creation.');
237
- }
238
-
239
- /**
240
- * Do not overwrite existing files
241
- */
242
- if (fs.existsSync(destPath)) {
243
- throw new CliError(`Path already exists ${destPath}`);
244
- }
245
-
246
- const choices: CliChoice<ModuleTemplate>[] = ALL_MODULE_TEMPLATES.map(target => ({
247
- name: `${wrapInColor(target.name, ANSI_COLORS.GREEN_COLOR)} . ${target.description}`,
248
- value: target,
249
- }));
250
-
251
- const templateOption = argv.getArgument('template');
252
- const template = templateOption ? ALL_MODULE_TEMPLATES.find(template => template.path === templateOption) : undefined;
253
- const moduleTemplate = template ?? await getUserChoice(choices, `Please choose the module type:`);
254
-
255
- /**
256
- * Copy bootstrap files
257
- */
258
- const sourcePath = path.join(BOOTSTRAP_DIR_PATH, 'modules', moduleTemplate.path);
259
- const replacements: Replacements = {
260
- MODULE_NAME: moduleName,
261
- MODULE_NAME_PASCAL_CASED: toPascalCase(moduleName),
262
- };
263
-
264
- copyBootstrapFiles(sourcePath, destPath, replacements);
265
-
266
- // Finalize message
267
- console.log(`Success! New module directory: ${wrapInColor(destPath, ANSI_COLORS.GREEN_COLOR)}`);
268
- }
269
-
270
- export const command = `new_module [module-name]`;
271
- export const describe = referenceString;
272
- export const builder = (yargs: Argv<CommandParameters>) => {
273
- yargs
274
- .positional('module-name', {
275
- describe: 'Name of the Valdi module.',
276
- })
277
- .option('template', {
278
- describe: 'module template to use, will skip the prompt',
279
- choices: ALL_MODULE_TEMPLATES.map(template => template.path),
280
- })
281
- .option('skip-checks', {
282
- describe: 'Skips confirmation prompts.',
283
- type: 'boolean',
284
- });
285
- };
286
- export const handler = makeCommandHandler(valdiNewModule);
@@ -1,102 +0,0 @@
1
- import * as fs from 'fs';
2
- import path from 'path';
3
- import type { Argv } from 'yargs';
4
- import type { PLATFORM } from '../core/constants';
5
- import { ALL_ARCHITECTURES, ANSI_COLORS } from '../core/constants';
6
- import { CliError } from '../core/errors';
7
- import type { ArgumentsResolver } from '../utils/ArgumentsResolver';
8
- import { BazelClient } from '../utils/BazelClient';
9
- import type { SharedCommandParameters } from '../utils/applicationUtils';
10
- import {
11
- applicationExtensionForPlatform,
12
- getApplicationTargetTagForPlatform,
13
- getOutputFilePath,
14
- makeArgsBuilder,
15
- resolveBazelBuildArgs,
16
- selectBazelTarget,
17
- } from '../utils/applicationUtils';
18
- import { logReproduceThisCommandIfNeeded, makeCommandHandler } from '../utils/errorUtils';
19
- import { wrapInColor } from '../utils/logUtils';
20
-
21
- interface CommandParameters extends SharedCommandParameters {
22
- application: string | undefined;
23
- target_output_path: string | undefined;
24
- output_path: string;
25
- }
26
-
27
- async function valdiPackage(argv: ArgumentsResolver<CommandParameters>): Promise<void> {
28
- const bazel = new BazelClient();
29
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
30
- const platform = argv.getArgument('platform') as PLATFORM;
31
- const bazelArgs = resolveBazelBuildArgs(
32
- platform,
33
- argv.getArgument('build_config'),
34
- ALL_ARCHITECTURES,
35
- /* forDevice */ true,
36
- argv.getArgument('enable_runtime_logs'),
37
- argv.getArgument('enable_runtime_traces'),
38
- argv.getArgument('bazel_args'),
39
- );
40
-
41
- const resolvedOutputPath = path.resolve(argv.getArgument('output_path'));
42
- const expectedExtension = applicationExtensionForPlatform(platform);
43
- if (expectedExtension.length > 0 && !resolvedOutputPath.endsWith(expectedExtension)) {
44
- throw new CliError(`Output path for platform '${platform}' must have ${expectedExtension} file extension`);
45
- }
46
-
47
- if (fs.existsSync(resolvedOutputPath)) {
48
- fs.rmSync(resolvedOutputPath);
49
- }
50
- const directoryPath = path.dirname(resolvedOutputPath);
51
- if (!fs.existsSync(directoryPath)) {
52
- fs.mkdirSync(directoryPath, { recursive: true });
53
- }
54
-
55
- const application = await argv.getArgumentOrResolve('application', () => {
56
- console.log('No application specified querying available targets...');
57
- return selectBazelTarget(
58
- bazel,
59
- getApplicationTargetTagForPlatform(platform),
60
- 'valdi_application',
61
- 'Please select an application target to package:',
62
- );
63
- });
64
- console.log('Resolving output paths...');
65
-
66
- const bazelOutputFilePath = await argv.getArgumentOrResolve('target_output_path', () => {
67
- console.log('Resolving output paths...');
68
- return getOutputFilePath(bazel, expectedExtension, application, bazelArgs);
69
- });
70
- console.log(`Building: ${wrapInColor(application, ANSI_COLORS.GREEN_COLOR)}`);
71
-
72
- await bazel.buildTarget(application, bazelArgs);
73
-
74
- console.log(`Copying built target to ${resolvedOutputPath}...`);
75
- await fs.promises.copyFile(bazelOutputFilePath, resolvedOutputPath);
76
-
77
- logReproduceThisCommandIfNeeded(argv);
78
- console.log('All done!');
79
- }
80
-
81
- export const command = 'package <platform>';
82
- export const describe = 'Build and package a Valdi application';
83
- export const builder = makeArgsBuilder((yargs: Argv<CommandParameters>) => {
84
- yargs
85
- .option('application', {
86
- describe: 'Name of the application to build',
87
- type: 'string',
88
- requiresArg: true,
89
- })
90
- .option('target_output_path', {
91
- describe: 'The output path for the Bazel target',
92
- type: 'string',
93
- requiresArg: true,
94
- })
95
- .option('output_path', {
96
- describe: 'The path where to store the built application package',
97
- type: 'string',
98
- requiresArg: true,
99
- })
100
- .demandOption('output_path');
101
- });
102
- export const handler = makeCommandHandler(valdiPackage);