@snap/valdi 1.0.7 → 1.0.11
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/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/BUILD.bazel.template +16 -1
- package/.bootstrap/modules/polyglot_bridge_module/web/Calculator.ts +11 -0
- package/.bootstrap/modules/polyglot_bridge_module/web/tsconfig.json +16 -0
- package/.bootstrap/modules/polyglot_view_module/BUILD.bazel.template +75 -0
- package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeView.kt.template +41 -0
- package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeViewAttributesBinder.kt.template +17 -0
- package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.h +8 -0
- package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.m +23 -0
- package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.h +8 -0
- package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.m +23 -0
- package/.bootstrap/modules/polyglot_view_module/src/PolyglotCustomView.tsx.template +23 -0
- package/.bootstrap/modules/polyglot_view_module/web/PolyglotWeb.ts.template +30 -0
- package/.bootstrap/modules/polyglot_view_module/web/tsconfig.json +16 -0
- package/.metadata/AGENTS.md.template +8 -274
- package/.metadata/skill-reference.tsx.template +8 -0
- package/.metadata/skill-tests-BUILD.bazel.template +21 -0
- package/.metadata/skill-tests-README.md.template +17 -0
- package/.metadata/skill.md.template +27 -0
- package/README.md +12 -3
- package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
- package/bundled-skills/registry.json +21 -0
- package/bundled-skills/skills/valdi-android/skill.md +89 -0
- package/bundled-skills/skills/valdi-async/skill.md +246 -0
- package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
- package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
- package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
- package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
- package/bundled-skills/skills/valdi-bazel/skill.md +141 -0
- package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
- package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
- package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
- package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
- package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
- package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
- package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
- package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
- package/bundled-skills/skills/valdi-custom-view/skill.md +64 -0
- package/bundled-skills/skills/valdi-inspect/skill.md +199 -0
- package/bundled-skills/skills/valdi-ios/skill.md +93 -0
- package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
- package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
- package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
- package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
- package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
- package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
- package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
- package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
- package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
- package/bundled-skills/skills/valdi-overview/skill.md +63 -0
- package/bundled-skills/skills/valdi-perf/skill.md +197 -0
- package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
- package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
- package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
- package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
- package/bundled-skills/skills/valdi-polyglot-module/skill.md +124 -0
- package/bundled-skills/skills/valdi-profile/skill.md +126 -0
- package/bundled-skills/skills/valdi-setup/skill.md +129 -0
- package/bundled-skills/skills/valdi-testing/skill.md +65 -0
- package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
- package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
- package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
- package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
- package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
- package/dist/commands/bootstrap.js +0 -7
- package/dist/commands/inspect.js +16 -0
- package/dist/commands/inspect_commands/contexts.js +55 -0
- package/dist/commands/inspect_commands/devices.js +53 -0
- package/dist/commands/inspect_commands/heap.js +59 -0
- package/dist/commands/inspect_commands/select.js +43 -0
- package/dist/commands/inspect_commands/snapshot.js +64 -0
- package/dist/commands/inspect_commands/status.js +68 -0
- package/dist/commands/inspect_commands/tree.js +86 -0
- package/dist/commands/newModule.js +10 -14
- package/dist/commands/profile.js +16 -0
- package/dist/commands/profile_commands/capture.js +106 -0
- package/dist/commands/skills.js +16 -0
- package/dist/commands/skills_commands/create.js +125 -0
- package/dist/commands/skills_commands/install.js +96 -0
- package/dist/commands/skills_commands/list.js +83 -0
- package/dist/commands/skills_commands/remove.js +41 -0
- package/dist/commands/skills_commands/update.js +59 -0
- package/dist/core/constants.js +0 -1
- package/dist/core/packageFiles.spec.js +29 -0
- package/dist/setup/versions.js +1 -1
- package/dist/utils/daemonClient.js +342 -0
- package/dist/utils/hermesClient.js +252 -0
- package/dist/utils/skillsAdapters.js +140 -0
- package/dist/utils/skillsRegistry.js +40 -0
- package/dist/utils/stringUtils.spec.js +1 -1
- package/package.json +20 -5
- package/.bazelignore +0 -2
- package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
- package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
- package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
- package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
- package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
- package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
- package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
- package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
- package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
- package/.config/copyconfig.json +0 -10
- package/.editorconfig +0 -21
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -72
- package/.github/README.md +0 -164
- package/.metadata/.cursorrules.template +0 -60
- package/.prettierignore +0 -2
- package/.prettierrc.json +0 -7
- package/LINUX_COMPATIBILITY.md +0 -248
- package/prettier.config.js +0 -4
- package/scripts/sync-agents-md.sh +0 -44
- package/scripts/update-agents-templates.ts +0 -170
- package/spec/support/jasmine.json +0 -6
- package/src/commands/bootstrap.ts +0 -410
- package/src/commands/build.ts +0 -89
- package/src/commands/devSetup.ts +0 -17
- package/src/commands/doctor.ts +0 -1832
- package/src/commands/export.ts +0 -131
- package/src/commands/hotreload.ts +0 -108
- package/src/commands/install.ts +0 -93
- package/src/commands/lint.ts +0 -15
- package/src/commands/lint_commands/lintCheck.ts +0 -53
- package/src/commands/lint_commands/lintFormat.ts +0 -49
- package/src/commands/log.ts +0 -108
- package/src/commands/newModule.ts +0 -286
- package/src/commands/package.ts +0 -102
- package/src/commands/projectsync.ts +0 -488
- package/src/commands/test.ts +0 -68
- package/src/core/constants.ts +0 -98
- package/src/core/errors.ts +0 -10
- package/src/index.ts +0 -27
- package/src/setup/DevSetupHelper.ts +0 -290
- package/src/setup/linuxSetup.ts +0 -261
- package/src/setup/macOSSetup.ts +0 -156
- package/src/setup/setupEntryPoint.ts +0 -64
- package/src/setup/versions.ts +0 -8
- package/src/utils/ArgumentsResolver.ts +0 -23
- package/src/utils/BazelClient.ts +0 -285
- package/src/utils/Digraph.ts +0 -81
- package/src/utils/LoadingIndicator.ts +0 -43
- package/src/utils/applicationUtils.ts +0 -276
- package/src/utils/buildInfo.ts +0 -99
- package/src/utils/byString.ts +0 -3
- package/src/utils/cliUtils.ts +0 -112
- package/src/utils/copyBootstrapFiles.ts +0 -30
- package/src/utils/deviceUtils.ts +0 -76
- package/src/utils/errorUtils.ts +0 -63
- package/src/utils/fileUtils.ts +0 -257
- package/src/utils/githubUtils.ts +0 -102
- package/src/utils/jsonUtils.ts +0 -30
- package/src/utils/lintUtils.ts +0 -190
- package/src/utils/linuxDistro.spec.ts +0 -219
- package/src/utils/linuxDistro.ts +0 -326
- package/src/utils/logUtils.ts +0 -9
- package/src/utils/pathUtils.ts +0 -12
- package/src/utils/stringUtils.spec.ts +0 -95
- package/src/utils/stringUtils.ts +0 -103
- package/src/utils/tempDir.ts +0 -24
- package/src/utils/zipUtils.ts +0 -14
- package/test/ValdiSmokeTest.ts +0 -279
- package/test/helpers/AsyncHelpers.ts +0 -113
- package/test/helpers/CommandHelpers.ts +0 -37
- package/test/helpers/ProjectHelpers.ts +0 -153
- package/test/helpers/StreamHelpers.ts +0 -37
- package/test/helpers/TypeScriptClient.ts +0 -217
- package/tsconfig.dist.json +0 -8
- package/tsconfig.json +0 -42
- /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/android/CalculatorModuleFactory.kt.template +0 -0
- /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/ios/SCCCalculatorModuleFactory.m.template +0 -0
- /package/.bootstrap/modules/{cpp_bridge_module → polyglot_bridge_module}/src/Calculator.d.ts +0 -0
package/src/commands/export.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import type { Argv } from 'yargs';
|
|
4
|
-
import { ALL_ARCHITECTURES, ANSI_COLORS, PLATFORM } from '../core/constants';
|
|
5
|
-
import { CliError } from '../core/errors';
|
|
6
|
-
import type { ArgumentsResolver } from '../utils/ArgumentsResolver';
|
|
7
|
-
import { BazelClient } from '../utils/BazelClient';
|
|
8
|
-
import type { SharedCommandParameters } from '../utils/applicationUtils';
|
|
9
|
-
import {
|
|
10
|
-
exportedLibraryExtensionForPlatform,
|
|
11
|
-
getExportedLibraryTargetTagForPlatform,
|
|
12
|
-
getOutputFilePath,
|
|
13
|
-
makeArgsBuilder,
|
|
14
|
-
resolveBazelBuildArgs,
|
|
15
|
-
selectBazelTarget,
|
|
16
|
-
} from '../utils/applicationUtils';
|
|
17
|
-
import { logReproduceThisCommandIfNeeded, makeCommandHandler } from '../utils/errorUtils';
|
|
18
|
-
import { removeFileOrDirAtPath } from '../utils/fileUtils';
|
|
19
|
-
import { wrapInColor } from '../utils/logUtils';
|
|
20
|
-
import { withTempDir } from '../utils/tempDir';
|
|
21
|
-
import { decompressTo } from '../utils/zipUtils';
|
|
22
|
-
|
|
23
|
-
interface CommandParameters extends SharedCommandParameters {
|
|
24
|
-
library: string | undefined;
|
|
25
|
-
target_output_path: string | undefined;
|
|
26
|
-
output_path: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function decompressAndMoveXCFrameworkIntoDestination(
|
|
30
|
-
bazelOutputFilePath: string,
|
|
31
|
-
resolvedOutputPath: string,
|
|
32
|
-
): Promise<void> {
|
|
33
|
-
await withTempDir(async tempDir => {
|
|
34
|
-
await decompressTo(bazelOutputFilePath, tempDir);
|
|
35
|
-
|
|
36
|
-
const decompressedOutputs = fs.readdirSync(tempDir);
|
|
37
|
-
if (decompressedOutputs.length !== 1) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
`Expected 1 unzipped output, got ${decompressedOutputs.length} (${decompressedOutputs.join(', ')})`,
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
|
-
const inputDir = path.join(tempDir, decompressedOutputs[0]!);
|
|
45
|
-
|
|
46
|
-
await fs.promises.rename(inputDir, resolvedOutputPath);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async function valdiExport(argv: ArgumentsResolver<CommandParameters>): Promise<void> {
|
|
51
|
-
const bazel = new BazelClient();
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
|
-
const platform = argv.getArgument('platform') as PLATFORM;
|
|
54
|
-
const bazelArgs = resolveBazelBuildArgs(
|
|
55
|
-
platform,
|
|
56
|
-
argv.getArgument('build_config'),
|
|
57
|
-
ALL_ARCHITECTURES,
|
|
58
|
-
/* forDevice */ false,
|
|
59
|
-
argv.getArgument('enable_runtime_logs'),
|
|
60
|
-
argv.getArgument('enable_runtime_traces'),
|
|
61
|
-
argv.getArgument('bazel_args'),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const resolvedOutputPath = path.resolve(argv.getArgument('output_path'));
|
|
65
|
-
const expectedExtension = exportedLibraryExtensionForPlatform(platform);
|
|
66
|
-
if (!resolvedOutputPath.endsWith(expectedExtension)) {
|
|
67
|
-
throw new CliError(`Output path for platform '${platform}' must have ${expectedExtension} file extension`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
removeFileOrDirAtPath(resolvedOutputPath);
|
|
71
|
-
const directoryPath = path.dirname(resolvedOutputPath);
|
|
72
|
-
if (!fs.existsSync(directoryPath)) {
|
|
73
|
-
fs.mkdirSync(directoryPath, { recursive: true });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const library = await argv.getArgumentOrResolve('library', () => {
|
|
77
|
-
console.log('No library specified querying available targets...');
|
|
78
|
-
return selectBazelTarget(
|
|
79
|
-
bazel,
|
|
80
|
-
getExportedLibraryTargetTagForPlatform(platform),
|
|
81
|
-
'valdi_exported_library',
|
|
82
|
-
'Please select a library to export:',
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
console.log('Resolving output paths...');
|
|
87
|
-
|
|
88
|
-
const bazelOutputExtension = platform === PLATFORM.IOS ? '.zip' : expectedExtension;
|
|
89
|
-
const bazelOutputFilePath = await argv.getArgumentOrResolve('target_output_path', () => {
|
|
90
|
-
console.log('Resolving output paths...');
|
|
91
|
-
return getOutputFilePath(bazel, bazelOutputExtension, library, bazelArgs);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
console.log(`Building: ${wrapInColor(library, ANSI_COLORS.GREEN_COLOR)}`);
|
|
95
|
-
|
|
96
|
-
await bazel.buildTarget(library, bazelArgs);
|
|
97
|
-
|
|
98
|
-
console.log(`Copying built target to ${resolvedOutputPath}...`);
|
|
99
|
-
if (platform === PLATFORM.IOS) {
|
|
100
|
-
await decompressAndMoveXCFrameworkIntoDestination(bazelOutputFilePath, resolvedOutputPath);
|
|
101
|
-
} else {
|
|
102
|
-
await fs.promises.copyFile(bazelOutputFilePath, resolvedOutputPath);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
logReproduceThisCommandIfNeeded(argv);
|
|
106
|
-
|
|
107
|
-
console.log('All done!');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export const command = 'export <platform>';
|
|
111
|
-
export const describe = 'Build and export a Valdi library';
|
|
112
|
-
export const builder = makeArgsBuilder((yargs: Argv<CommandParameters>) => {
|
|
113
|
-
yargs
|
|
114
|
-
.option('library', {
|
|
115
|
-
describe: 'Name of the library to build',
|
|
116
|
-
type: 'string',
|
|
117
|
-
requiresArg: true,
|
|
118
|
-
})
|
|
119
|
-
.option('target_output_path', {
|
|
120
|
-
describe: 'The output path for the Bazel target',
|
|
121
|
-
type: 'string',
|
|
122
|
-
requiresArg: true,
|
|
123
|
-
})
|
|
124
|
-
.option('output_path', {
|
|
125
|
-
describe: 'The path where to store the built application package',
|
|
126
|
-
type: 'string',
|
|
127
|
-
requiresArg: true,
|
|
128
|
-
})
|
|
129
|
-
.demandOption('output_path');
|
|
130
|
-
});
|
|
131
|
-
export const handler = makeCommandHandler(valdiExport);
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type { Argv } from 'yargs';
|
|
2
|
-
import { ANSI_COLORS } from '../core/constants';
|
|
3
|
-
import { CliError } from '../core/errors';
|
|
4
|
-
import type { ArgumentsResolver } from '../utils/ArgumentsResolver';
|
|
5
|
-
import { BazelClient } from '../utils/BazelClient';
|
|
6
|
-
import type { CliChoice } from '../utils/cliUtils';
|
|
7
|
-
import { getUserChoice, spawnCliCommand } from '../utils/cliUtils';
|
|
8
|
-
import { logReproduceThisCommandIfNeeded, makeCommandHandler } from '../utils/errorUtils';
|
|
9
|
-
import { wrapInColor } from '../utils/logUtils';
|
|
10
|
-
|
|
11
|
-
interface CommandParameters {
|
|
12
|
-
module: string | undefined;
|
|
13
|
-
target: string | undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function hotreloadResolvedTarget(client: BazelClient, resolvedTarget: string) {
|
|
17
|
-
await client.buildTarget(resolvedTarget);
|
|
18
|
-
const workspaceRoot = await client.getWorkspaceRoot();
|
|
19
|
-
const buildOutputs = await client.queryBuildOutputs([resolvedTarget]);
|
|
20
|
-
|
|
21
|
-
if (buildOutputs.length === 0) {
|
|
22
|
-
throw new CliError(`No build outputs found for target: ${resolvedTarget}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const hotreloadCommand = buildOutputs[0] ?? '';
|
|
26
|
-
|
|
27
|
-
await spawnCliCommand(hotreloadCommand, workspaceRoot, 'inherit', true, false);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function hotreloadTarget(client: BazelClient, target: string) {
|
|
31
|
-
const resolvedLabel = await client.resolveLabel(target);
|
|
32
|
-
let resolvedTarget: string;
|
|
33
|
-
if (resolvedLabel.name) {
|
|
34
|
-
resolvedTarget = resolvedLabel.toString();
|
|
35
|
-
} else {
|
|
36
|
-
const targets = await client.query(`kind('valdi_hotreload', ${resolvedLabel.toString()}/...)`);
|
|
37
|
-
if (targets.length === 0) {
|
|
38
|
-
throw new Error(`Could not resolve hot reload target for label ${resolvedLabel.toString()}`);
|
|
39
|
-
}
|
|
40
|
-
if (targets.length !== 1) {
|
|
41
|
-
throw new Error(`Resolved more than 1 hot reload target for ${resolvedLabel.toString()}: ${targets.join(',')}`);
|
|
42
|
-
}
|
|
43
|
-
resolvedTarget = targets[0] as string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
await hotreloadResolvedTarget(client, resolvedTarget);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function getHotreloadTargetByModuleName(client: BazelClient, moduleName: string): Promise<string> {
|
|
50
|
-
const targets = await client.query(`filter(${moduleName}_hotreload, kind('valdi_hotreload rule', //...))`);
|
|
51
|
-
if (targets.length === 0) {
|
|
52
|
-
throw new CliError(`No hotreload target found for module: ${moduleName}`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return targets[0]?.trim() ?? '';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async function valdiHotreload(argv: ArgumentsResolver<CommandParameters>) {
|
|
59
|
-
const client = new BazelClient();
|
|
60
|
-
|
|
61
|
-
// TODO(3136): Try discovering and building with default path to modules first
|
|
62
|
-
const target = await argv.getArgumentOrResolve('target', async () => {
|
|
63
|
-
const module = argv.getArgument('module');
|
|
64
|
-
if (module) {
|
|
65
|
-
console.log('Finding target for module:', wrapInColor(module, ANSI_COLORS.GREEN_COLOR));
|
|
66
|
-
const target = await getHotreloadTargetByModuleName(client, module);
|
|
67
|
-
console.log('Found target:', wrapInColor(target, ANSI_COLORS.GREEN_COLOR));
|
|
68
|
-
return target;
|
|
69
|
-
}
|
|
70
|
-
const targets = await client.query('attr("tags", "valdi_application", //...)');
|
|
71
|
-
if (targets.length === 0) {
|
|
72
|
-
throw new CliError(`Could not resolve Valdi application Bazel target`);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (targets.length === 1) {
|
|
76
|
-
return targets[0] as string;
|
|
77
|
-
} else {
|
|
78
|
-
const choices: Array<CliChoice<string>> = targets.map((target, index) => ({
|
|
79
|
-
name: `${index + 1}. ${target}`,
|
|
80
|
-
value: target,
|
|
81
|
-
}));
|
|
82
|
-
|
|
83
|
-
return await getUserChoice(choices, 'Please choose a target to hot reload:');
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
logReproduceThisCommandIfNeeded(argv);
|
|
88
|
-
|
|
89
|
-
await hotreloadResolvedTarget(client, target);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export const command = 'hotreload [--module module_name] [--target target_name]';
|
|
93
|
-
export const describe = 'Starts the hotreloader for the application';
|
|
94
|
-
export const builder = (yargs: Argv<CommandParameters>) => {
|
|
95
|
-
yargs
|
|
96
|
-
.option('module', {
|
|
97
|
-
describe: 'Name of the module to hotreload',
|
|
98
|
-
type: 'string',
|
|
99
|
-
requiresArg: true,
|
|
100
|
-
})
|
|
101
|
-
.option('target', {
|
|
102
|
-
describe: 'Bazel target path to hotreload',
|
|
103
|
-
type: 'string',
|
|
104
|
-
requiresArg: true,
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const handler = makeCommandHandler(valdiHotreload);
|
package/src/commands/install.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { type Argv } from 'yargs';
|
|
2
|
-
import { ANSI_COLORS, PLATFORM } from '../core/constants';
|
|
3
|
-
import type { ArgumentsResolver } from '../utils/ArgumentsResolver';
|
|
4
|
-
import { BazelClient } from '../utils/BazelClient';
|
|
5
|
-
import {
|
|
6
|
-
applicationExtensionForPlatform,
|
|
7
|
-
getOutputFilePath,
|
|
8
|
-
makeArgsBuilder,
|
|
9
|
-
} from '../utils/applicationUtils';
|
|
10
|
-
import type { CommandParameters} from '../utils/buildInfo';
|
|
11
|
-
import { getBuildInfo } from '../utils/buildInfo';
|
|
12
|
-
import { installAndroidApk } from '../utils/deviceUtils';
|
|
13
|
-
import { logReproduceThisCommandIfNeeded, makeCommandHandler } from '../utils/errorUtils';
|
|
14
|
-
import { wrapInColor } from '../utils/logUtils';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
async function valdiInstall(argv: ArgumentsResolver<CommandParameters>) {
|
|
18
|
-
const bazel = new BazelClient();
|
|
19
|
-
|
|
20
|
-
const buildInfo = await getBuildInfo(argv, bazel, true);
|
|
21
|
-
|
|
22
|
-
// Output Selection
|
|
23
|
-
// ----------------
|
|
24
|
-
|
|
25
|
-
// Perform build and install
|
|
26
|
-
// -------------------------
|
|
27
|
-
console.log(`Building: ${wrapInColor(buildInfo.application, ANSI_COLORS.GREEN_COLOR)}`);
|
|
28
|
-
|
|
29
|
-
switch (buildInfo.platform) {
|
|
30
|
-
case PLATFORM.ANDROID: {
|
|
31
|
-
const outputFilePath = await argv.getArgumentOrResolve('target_output_path', () => {
|
|
32
|
-
console.log('Resolving output paths...');
|
|
33
|
-
return getOutputFilePath(bazel, applicationExtensionForPlatform(buildInfo.platform), buildInfo.application, buildInfo.bazelArgs);
|
|
34
|
-
});
|
|
35
|
-
await bazel.buildTarget(buildInfo.application, buildInfo.bazelArgs);
|
|
36
|
-
|
|
37
|
-
console.log('Installing Android application...');
|
|
38
|
-
await installAndroidApk(outputFilePath, buildInfo.selectedDevice);
|
|
39
|
-
logReproduceThisCommandIfNeeded(argv);
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
case PLATFORM.IOS: {
|
|
43
|
-
console.log('Installing iOS application...');
|
|
44
|
-
await bazel.runTarget(buildInfo.application, buildInfo.bazelArgs);
|
|
45
|
-
logReproduceThisCommandIfNeeded(argv);
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
case PLATFORM.MACOS: {
|
|
49
|
-
logReproduceThisCommandIfNeeded(argv);
|
|
50
|
-
console.log('Installing MacOS application...');
|
|
51
|
-
await bazel.runTarget(buildInfo.application, buildInfo.bazelArgs);
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
case PLATFORM.CLI: {
|
|
55
|
-
logReproduceThisCommandIfNeeded(argv);
|
|
56
|
-
console.log('Running CLI application...');
|
|
57
|
-
await bazel.runTarget(buildInfo.application, buildInfo.bazelArgs);
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const command = 'install <platform>';
|
|
64
|
-
export const describe = 'Build and install the application to the connected device';
|
|
65
|
-
export const builder = makeArgsBuilder((yargs: Argv<CommandParameters>) => {
|
|
66
|
-
yargs
|
|
67
|
-
.option('application', {
|
|
68
|
-
describe: 'Name of the application to install',
|
|
69
|
-
type: 'string',
|
|
70
|
-
requiresArg: true,
|
|
71
|
-
})
|
|
72
|
-
.option('device_id', {
|
|
73
|
-
describe: 'Device ID that will receive the application',
|
|
74
|
-
type: 'string',
|
|
75
|
-
requiresArg: true,
|
|
76
|
-
})
|
|
77
|
-
.option('target_output_path', {
|
|
78
|
-
describe: 'The output path for the Bazel target',
|
|
79
|
-
type: 'string',
|
|
80
|
-
requiresArg: true,
|
|
81
|
-
})
|
|
82
|
-
.option('simulator', {
|
|
83
|
-
describe: 'Whether to build for simulator or for device',
|
|
84
|
-
type: 'boolean',
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
export const handler = makeCommandHandler(valdiInstall);
|
|
88
|
-
|
|
89
|
-
// TODOs:
|
|
90
|
-
// - Cached bazel query results
|
|
91
|
-
|
|
92
|
-
// Extract 'custom_package' from android_binary
|
|
93
|
-
// Extract 'bundle_id' from ios_application target
|
package/src/commands/lint.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Argv } from 'yargs';
|
|
2
|
-
|
|
3
|
-
export const command = 'lint <command>';
|
|
4
|
-
export const describe = 'Checks and formats the code';
|
|
5
|
-
export const builder = (yargs: Argv) => {
|
|
6
|
-
return yargs
|
|
7
|
-
.commandDir('lint_commands', {
|
|
8
|
-
extensions: ['js', 'ts'],
|
|
9
|
-
})
|
|
10
|
-
.demandCommand(1, 'Use "check" or "format" to execute prettier')
|
|
11
|
-
.recommendCommands()
|
|
12
|
-
.wrap(yargs.terminalWidth())
|
|
13
|
-
.help();
|
|
14
|
-
};
|
|
15
|
-
export const handler = () => {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { Argv } from 'yargs';
|
|
2
|
-
import { ANSI_COLORS } from '../../core/constants';
|
|
3
|
-
import type { ArgumentsResolver } from '../../utils/ArgumentsResolver';
|
|
4
|
-
import { makeCommandHandler } from '../../utils/errorUtils';
|
|
5
|
-
import type { FileLintStatus } from '../../utils/lintUtils';
|
|
6
|
-
import {
|
|
7
|
-
checkAndFormatFiles,
|
|
8
|
-
getPrettierConfig,
|
|
9
|
-
maybeSetupEslint,
|
|
10
|
-
maybeSetupPrettier,
|
|
11
|
-
printStatus,
|
|
12
|
-
} from '../../utils/lintUtils';
|
|
13
|
-
import { wrapInColor } from '../../utils/logUtils';
|
|
14
|
-
|
|
15
|
-
interface CommandParameters {
|
|
16
|
-
files: string[] | undefined;
|
|
17
|
-
showSkipped: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async function lintCheck(argv: ArgumentsResolver<CommandParameters>) {
|
|
21
|
-
const configPath = await maybeSetupPrettier();
|
|
22
|
-
const prettierConfig = await getPrettierConfig(configPath);
|
|
23
|
-
await maybeSetupEslint();
|
|
24
|
-
|
|
25
|
-
console.log(`Using config at: ${wrapInColor(configPath, ANSI_COLORS.GREEN_COLOR)}\n`);
|
|
26
|
-
|
|
27
|
-
const filePaths = argv.getArgument('files');
|
|
28
|
-
|
|
29
|
-
if (filePaths === undefined || prettierConfig === null) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const results: FileLintStatus[] = await checkAndFormatFiles(filePaths, prettierConfig);
|
|
34
|
-
|
|
35
|
-
// Output list of files and their status
|
|
36
|
-
printStatus(results, argv.getArgument('showSkipped'));
|
|
37
|
-
|
|
38
|
-
// TODO (yhuang6): Implement the following
|
|
39
|
-
// Default checks changed files based on git
|
|
40
|
-
// Default checks the current directory otherwise
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const command = 'check [files..]';
|
|
44
|
-
export const describe = 'Checks the file formatting and lint rules';
|
|
45
|
-
export const builder = (yargs: Argv<CommandParameters>) => {
|
|
46
|
-
yargs.option('show-skipped', {
|
|
47
|
-
describe: 'Shows files skipped during linting (e.g. no format parsers)',
|
|
48
|
-
type: 'boolean',
|
|
49
|
-
alias: 's',
|
|
50
|
-
default: false,
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
export const handler = makeCommandHandler(lintCheck);
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { Argv } from 'yargs';
|
|
2
|
-
import { ANSI_COLORS } from '../../core/constants';
|
|
3
|
-
import type { ArgumentsResolver } from '../../utils/ArgumentsResolver';
|
|
4
|
-
import { makeCommandHandler } from '../../utils/errorUtils';
|
|
5
|
-
import type { FileLintStatus } from '../../utils/lintUtils';
|
|
6
|
-
import {
|
|
7
|
-
checkAndFormatFiles,
|
|
8
|
-
getPrettierConfig,
|
|
9
|
-
maybeSetupEslint,
|
|
10
|
-
maybeSetupPrettier,
|
|
11
|
-
printStatus,
|
|
12
|
-
} from '../../utils/lintUtils';
|
|
13
|
-
import { wrapInColor } from '../../utils/logUtils';
|
|
14
|
-
|
|
15
|
-
interface CommandParameters {
|
|
16
|
-
files: [string] | undefined;
|
|
17
|
-
showSkipped: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async function lintFormat(argv: ArgumentsResolver<CommandParameters>) {
|
|
21
|
-
const configPath = await maybeSetupPrettier();
|
|
22
|
-
const prettierConfig = await getPrettierConfig(configPath);
|
|
23
|
-
await maybeSetupEslint();
|
|
24
|
-
|
|
25
|
-
console.log(`Using config at: ${wrapInColor(configPath, ANSI_COLORS.GREEN_COLOR)}\n`);
|
|
26
|
-
|
|
27
|
-
const filePaths = argv.getArgument('files');
|
|
28
|
-
|
|
29
|
-
if (filePaths === undefined || prettierConfig === null) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const results: FileLintStatus[] = await checkAndFormatFiles(filePaths, prettierConfig, true);
|
|
34
|
-
|
|
35
|
-
// Output list of files and their status
|
|
36
|
-
printStatus(results, argv.getArgument('showSkipped'));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const command = 'format [files..]';
|
|
40
|
-
export const describe = 'Apply prettier formatting to files';
|
|
41
|
-
export const builder = (yargs: Argv<CommandParameters>) => {
|
|
42
|
-
yargs.option('show-skipped', {
|
|
43
|
-
describe: 'Shows files skipped during linting (e.g. no format parsers)',
|
|
44
|
-
type: 'boolean',
|
|
45
|
-
alias: 's',
|
|
46
|
-
default: false,
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
export const handler = makeCommandHandler(lintFormat);
|
package/src/commands/log.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { CliError } from '../core/errors';
|
|
4
|
-
import { getUserChoice } from '../utils/cliUtils';
|
|
5
|
-
import { makeCommandHandler } from '../utils/errorUtils';
|
|
6
|
-
import * as fileUtils from '../utils/fileUtils';
|
|
7
|
-
|
|
8
|
-
function readAndWatchFile(filePath: string) {
|
|
9
|
-
filePath = fileUtils.resolveFilePath(filePath);
|
|
10
|
-
|
|
11
|
-
let fileSize = 0;
|
|
12
|
-
let isWatching = false;
|
|
13
|
-
const abortController = new AbortController();
|
|
14
|
-
|
|
15
|
-
const readInitialContent = () => {
|
|
16
|
-
const fileStream = fs.createReadStream(filePath, { encoding: 'utf8', start: 0 });
|
|
17
|
-
|
|
18
|
-
fileStream.on('data', chunk => {
|
|
19
|
-
process.stdout.write(chunk);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
fileStream.on('end', () => {
|
|
23
|
-
fileSize = fs.statSync(filePath).size;
|
|
24
|
-
|
|
25
|
-
if (!isWatching) {
|
|
26
|
-
startWatching();
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const startWatching = () => {
|
|
32
|
-
isWatching = true;
|
|
33
|
-
fs.watch(filePath, { signal: abortController.signal }, eventType => {
|
|
34
|
-
if (eventType === 'change') {
|
|
35
|
-
const newFileSize = fs.statSync(filePath).size;
|
|
36
|
-
if (newFileSize > fileSize) {
|
|
37
|
-
const readStream = fs.createReadStream(filePath, { encoding: 'utf8', start: fileSize });
|
|
38
|
-
readStream.on('data', chunk => {
|
|
39
|
-
process.stdout.write(chunk);
|
|
40
|
-
});
|
|
41
|
-
fileSize = newFileSize;
|
|
42
|
-
}
|
|
43
|
-
} else if (eventType === 'rename') {
|
|
44
|
-
isWatching = false;
|
|
45
|
-
if (fs.existsSync(filePath)) {
|
|
46
|
-
// When files is written, sometimes the first reported event
|
|
47
|
-
// occurs when the write is incomplete, so verifying the file exists
|
|
48
|
-
// before reading and restarting the watch
|
|
49
|
-
readInitialContent();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
readInitialContent();
|
|
56
|
-
|
|
57
|
-
// Liten for (Ctrl+D) to exit as otherwise it would not do anything
|
|
58
|
-
process.stdin.on('end', () => {
|
|
59
|
-
abortController.abort();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Keep the process running
|
|
63
|
-
process.stdin.resume();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function showValdiLogs() {
|
|
67
|
-
const userConfig = fileUtils.getUserConfig();
|
|
68
|
-
|
|
69
|
-
if (userConfig.logs_output_dir === undefined) {
|
|
70
|
-
throw new CliError("Missing 'logs_output_dir' config value in config.yaml");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const allFilePaths = fileUtils.getFilesSortedByUpdatedTime(userConfig.logs_output_dir).filter(path => {
|
|
74
|
-
return path.endsWith('.log');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
if (allFilePaths.length <= 0) {
|
|
78
|
-
throw new CliError(
|
|
79
|
-
'No logs available. Please start up hot reloader and the app first to make sure there are logs available',
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let logPath = '';
|
|
84
|
-
|
|
85
|
-
if (allFilePaths.length === 1) {
|
|
86
|
-
logPath = allFilePaths[0] as string;
|
|
87
|
-
} else {
|
|
88
|
-
const choices = allFilePaths.map((filePath, index) => ({
|
|
89
|
-
name: `${index + 1}. ${path.basename(filePath)}`,
|
|
90
|
-
value: filePath,
|
|
91
|
-
}));
|
|
92
|
-
|
|
93
|
-
logPath = await getUserChoice(
|
|
94
|
-
choices,
|
|
95
|
-
'Please select the log file to use (this list is ordered by modification time, the most updated log will be displayed first):',
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
console.log(logPath);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Read and show log file content
|
|
102
|
-
readAndWatchFile(logPath);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export const command = 'log';
|
|
106
|
-
export const describe = 'Streams Valdi logs from the connected device to console';
|
|
107
|
-
export const builder = () => {};
|
|
108
|
-
export const handler = makeCommandHandler(showValdiLogs);
|