@valbuild/cli 0.73.1 → 0.74.0
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.
@@ -115,12 +115,19 @@ async function evalValConfigFile(projectRoot, configFileName) {
|
|
115
115
|
return result.data;
|
116
116
|
}
|
117
117
|
|
118
|
+
function getFileExt(filePath) {
|
119
|
+
// NOTE: We do not import the path module. This code is copied in different projects. We want the same implementation and which means that this might running in browser where path is not available).
|
120
|
+
return filePath.split(".").pop() || "";
|
121
|
+
}
|
122
|
+
|
123
|
+
const textEncoder = new TextEncoder();
|
118
124
|
async function validate({
|
119
125
|
root,
|
120
126
|
fix,
|
121
127
|
noEslint
|
122
128
|
}) {
|
123
129
|
const valRemoteHost = process.env.VAL_REMOTE_HOST || core.DEFAULT_VAL_REMOTE_HOST;
|
130
|
+
const contentHostUrl = process.env.VAL_CONTENT_URL || "https://content.val.build";
|
124
131
|
const projectRoot = root ? path__default["default"].resolve(root) : process.cwd();
|
125
132
|
const eslint$1 = new eslint.ESLint({
|
126
133
|
cwd: projectRoot,
|
@@ -319,8 +326,7 @@ async function validate({
|
|
319
326
|
console.log(picocolors__default["default"].yellow("⚠"), `Remote file ${filePath} already uploaded`);
|
320
327
|
continue;
|
321
328
|
}
|
322
|
-
// TODO: parallelize
|
323
|
-
console.log(picocolors__default["default"].yellow("⚠"), `Uploading remote file ${filePath}...`);
|
329
|
+
// TODO: parallelize uploading files
|
324
330
|
if (!resolvedRemoteFileAtSourcePath.schema) {
|
325
331
|
console.log(picocolors__default["default"].red("✘"), `Cannot upload remote file: schema not found for ${sourcePath}`);
|
326
332
|
errors += 1;
|
@@ -360,6 +366,11 @@ async function validate({
|
|
360
366
|
errors += 1;
|
361
367
|
continue;
|
362
368
|
}
|
369
|
+
if (!(valConfigFile !== null && valConfigFile !== void 0 && valConfigFile.project)) {
|
370
|
+
console.log(picocolors__default["default"].red("✘"), `Could not get project. Check that your val.config has the 'project' field set, or set it using the VAL_PROJECT environment variable`);
|
371
|
+
errors += 1;
|
372
|
+
continue;
|
373
|
+
}
|
363
374
|
if (resolveRemoteFileSchema.type !== "image" && resolveRemoteFileSchema.type !== "file") {
|
364
375
|
console.log(picocolors__default["default"].red("✘"), `The schema is the remote is neither image nor file: ${sourcePath}`);
|
365
376
|
}
|
@@ -384,17 +395,31 @@ async function validate({
|
|
384
395
|
errors += 1;
|
385
396
|
continue;
|
386
397
|
}
|
387
|
-
const
|
398
|
+
const fileHash = core.Internal.remote.getFileHash(fileBuffer);
|
399
|
+
const coreVersion = core.Internal.VERSION.core || "unknown";
|
400
|
+
const fileExt = getFileExt(filePath);
|
401
|
+
const schema = resolveRemoteFileSchema;
|
402
|
+
const metadata = fileSourceMetadata;
|
403
|
+
const ref = core.Internal.remote.createRemoteRef(valRemoteHost, {
|
404
|
+
publicProjectId,
|
405
|
+
coreVersion,
|
406
|
+
bucket,
|
407
|
+
validationHash: core.Internal.remote.getValidationHash(coreVersion, schema, fileExt, metadata, fileHash, textEncoder),
|
408
|
+
fileHash,
|
409
|
+
filePath: relativeFilePath
|
410
|
+
});
|
411
|
+
console.log(picocolors__default["default"].yellow("⚠"), `Uploading remote file: '${ref}'...`);
|
412
|
+
const remoteFileUpload = await server.uploadRemoteFile(contentHostUrl, valConfigFile.project, bucket, fileHash, fileExt, fileBuffer, {
|
388
413
|
pat
|
389
414
|
});
|
390
415
|
if (!remoteFileUpload.success) {
|
391
|
-
console.log(picocolors__default["default"].red("✘"), `
|
416
|
+
console.log(picocolors__default["default"].red("✘"), `Could not upload remote file: '${ref}'. Error: ${remoteFileUpload.error}`);
|
392
417
|
errors += 1;
|
393
418
|
continue;
|
394
419
|
}
|
395
|
-
console.log(picocolors__default["default"].
|
420
|
+
console.log(picocolors__default["default"].green("✔"), `Completed upload of remote file: '${ref}'`);
|
396
421
|
remoteFiles[sourcePath] = {
|
397
|
-
ref
|
422
|
+
ref,
|
398
423
|
metadata: fileSourceMetadata
|
399
424
|
};
|
400
425
|
}
|
@@ -115,12 +115,19 @@ async function evalValConfigFile(projectRoot, configFileName) {
|
|
115
115
|
return result.data;
|
116
116
|
}
|
117
117
|
|
118
|
+
function getFileExt(filePath) {
|
119
|
+
// NOTE: We do not import the path module. This code is copied in different projects. We want the same implementation and which means that this might running in browser where path is not available).
|
120
|
+
return filePath.split(".").pop() || "";
|
121
|
+
}
|
122
|
+
|
123
|
+
const textEncoder = new TextEncoder();
|
118
124
|
async function validate({
|
119
125
|
root,
|
120
126
|
fix,
|
121
127
|
noEslint
|
122
128
|
}) {
|
123
129
|
const valRemoteHost = process.env.VAL_REMOTE_HOST || core.DEFAULT_VAL_REMOTE_HOST;
|
130
|
+
const contentHostUrl = process.env.VAL_CONTENT_URL || "https://content.val.build";
|
124
131
|
const projectRoot = root ? path__default["default"].resolve(root) : process.cwd();
|
125
132
|
const eslint$1 = new eslint.ESLint({
|
126
133
|
cwd: projectRoot,
|
@@ -319,8 +326,7 @@ async function validate({
|
|
319
326
|
console.log(picocolors__default["default"].yellow("⚠"), `Remote file ${filePath} already uploaded`);
|
320
327
|
continue;
|
321
328
|
}
|
322
|
-
// TODO: parallelize
|
323
|
-
console.log(picocolors__default["default"].yellow("⚠"), `Uploading remote file ${filePath}...`);
|
329
|
+
// TODO: parallelize uploading files
|
324
330
|
if (!resolvedRemoteFileAtSourcePath.schema) {
|
325
331
|
console.log(picocolors__default["default"].red("✘"), `Cannot upload remote file: schema not found for ${sourcePath}`);
|
326
332
|
errors += 1;
|
@@ -360,6 +366,11 @@ async function validate({
|
|
360
366
|
errors += 1;
|
361
367
|
continue;
|
362
368
|
}
|
369
|
+
if (!(valConfigFile !== null && valConfigFile !== void 0 && valConfigFile.project)) {
|
370
|
+
console.log(picocolors__default["default"].red("✘"), `Could not get project. Check that your val.config has the 'project' field set, or set it using the VAL_PROJECT environment variable`);
|
371
|
+
errors += 1;
|
372
|
+
continue;
|
373
|
+
}
|
363
374
|
if (resolveRemoteFileSchema.type !== "image" && resolveRemoteFileSchema.type !== "file") {
|
364
375
|
console.log(picocolors__default["default"].red("✘"), `The schema is the remote is neither image nor file: ${sourcePath}`);
|
365
376
|
}
|
@@ -384,17 +395,31 @@ async function validate({
|
|
384
395
|
errors += 1;
|
385
396
|
continue;
|
386
397
|
}
|
387
|
-
const
|
398
|
+
const fileHash = core.Internal.remote.getFileHash(fileBuffer);
|
399
|
+
const coreVersion = core.Internal.VERSION.core || "unknown";
|
400
|
+
const fileExt = getFileExt(filePath);
|
401
|
+
const schema = resolveRemoteFileSchema;
|
402
|
+
const metadata = fileSourceMetadata;
|
403
|
+
const ref = core.Internal.remote.createRemoteRef(valRemoteHost, {
|
404
|
+
publicProjectId,
|
405
|
+
coreVersion,
|
406
|
+
bucket,
|
407
|
+
validationHash: core.Internal.remote.getValidationHash(coreVersion, schema, fileExt, metadata, fileHash, textEncoder),
|
408
|
+
fileHash,
|
409
|
+
filePath: relativeFilePath
|
410
|
+
});
|
411
|
+
console.log(picocolors__default["default"].yellow("⚠"), `Uploading remote file: '${ref}'...`);
|
412
|
+
const remoteFileUpload = await server.uploadRemoteFile(contentHostUrl, valConfigFile.project, bucket, fileHash, fileExt, fileBuffer, {
|
388
413
|
pat
|
389
414
|
});
|
390
415
|
if (!remoteFileUpload.success) {
|
391
|
-
console.log(picocolors__default["default"].red("✘"), `
|
416
|
+
console.log(picocolors__default["default"].red("✘"), `Could not upload remote file: '${ref}'. Error: ${remoteFileUpload.error}`);
|
392
417
|
errors += 1;
|
393
418
|
continue;
|
394
419
|
}
|
395
|
-
console.log(picocolors__default["default"].
|
420
|
+
console.log(picocolors__default["default"].green("✔"), `Completed upload of remote file: '${ref}'`);
|
396
421
|
remoteFiles[sourcePath] = {
|
397
|
-
ref
|
422
|
+
ref,
|
398
423
|
metadata: fileSourceMetadata
|
399
424
|
};
|
400
425
|
}
|
@@ -83,12 +83,19 @@ async function evalValConfigFile(projectRoot, configFileName) {
|
|
83
83
|
return result.data;
|
84
84
|
}
|
85
85
|
|
86
|
+
function getFileExt(filePath) {
|
87
|
+
// NOTE: We do not import the path module. This code is copied in different projects. We want the same implementation and which means that this might running in browser where path is not available).
|
88
|
+
return filePath.split(".").pop() || "";
|
89
|
+
}
|
90
|
+
|
91
|
+
const textEncoder = new TextEncoder();
|
86
92
|
async function validate({
|
87
93
|
root,
|
88
94
|
fix,
|
89
95
|
noEslint
|
90
96
|
}) {
|
91
97
|
const valRemoteHost = process.env.VAL_REMOTE_HOST || DEFAULT_VAL_REMOTE_HOST;
|
98
|
+
const contentHostUrl = process.env.VAL_CONTENT_URL || "https://content.val.build";
|
92
99
|
const projectRoot = root ? path.resolve(root) : process.cwd();
|
93
100
|
const eslint = new ESLint({
|
94
101
|
cwd: projectRoot,
|
@@ -287,8 +294,7 @@ async function validate({
|
|
287
294
|
console.log(picocolors.yellow("⚠"), `Remote file ${filePath} already uploaded`);
|
288
295
|
continue;
|
289
296
|
}
|
290
|
-
// TODO: parallelize
|
291
|
-
console.log(picocolors.yellow("⚠"), `Uploading remote file ${filePath}...`);
|
297
|
+
// TODO: parallelize uploading files
|
292
298
|
if (!resolvedRemoteFileAtSourcePath.schema) {
|
293
299
|
console.log(picocolors.red("✘"), `Cannot upload remote file: schema not found for ${sourcePath}`);
|
294
300
|
errors += 1;
|
@@ -328,6 +334,11 @@ async function validate({
|
|
328
334
|
errors += 1;
|
329
335
|
continue;
|
330
336
|
}
|
337
|
+
if (!(valConfigFile !== null && valConfigFile !== void 0 && valConfigFile.project)) {
|
338
|
+
console.log(picocolors.red("✘"), `Could not get project. Check that your val.config has the 'project' field set, or set it using the VAL_PROJECT environment variable`);
|
339
|
+
errors += 1;
|
340
|
+
continue;
|
341
|
+
}
|
331
342
|
if (resolveRemoteFileSchema.type !== "image" && resolveRemoteFileSchema.type !== "file") {
|
332
343
|
console.log(picocolors.red("✘"), `The schema is the remote is neither image nor file: ${sourcePath}`);
|
333
344
|
}
|
@@ -352,17 +363,31 @@ async function validate({
|
|
352
363
|
errors += 1;
|
353
364
|
continue;
|
354
365
|
}
|
355
|
-
const
|
366
|
+
const fileHash = Internal.remote.getFileHash(fileBuffer);
|
367
|
+
const coreVersion = Internal.VERSION.core || "unknown";
|
368
|
+
const fileExt = getFileExt(filePath);
|
369
|
+
const schema = resolveRemoteFileSchema;
|
370
|
+
const metadata = fileSourceMetadata;
|
371
|
+
const ref = Internal.remote.createRemoteRef(valRemoteHost, {
|
372
|
+
publicProjectId,
|
373
|
+
coreVersion,
|
374
|
+
bucket,
|
375
|
+
validationHash: Internal.remote.getValidationHash(coreVersion, schema, fileExt, metadata, fileHash, textEncoder),
|
376
|
+
fileHash,
|
377
|
+
filePath: relativeFilePath
|
378
|
+
});
|
379
|
+
console.log(picocolors.yellow("⚠"), `Uploading remote file: '${ref}'...`);
|
380
|
+
const remoteFileUpload = await uploadRemoteFile(contentHostUrl, valConfigFile.project, bucket, fileHash, fileExt, fileBuffer, {
|
356
381
|
pat
|
357
382
|
});
|
358
383
|
if (!remoteFileUpload.success) {
|
359
|
-
console.log(picocolors.red("✘"), `
|
384
|
+
console.log(picocolors.red("✘"), `Could not upload remote file: '${ref}'. Error: ${remoteFileUpload.error}`);
|
360
385
|
errors += 1;
|
361
386
|
continue;
|
362
387
|
}
|
363
|
-
console.log(picocolors.
|
388
|
+
console.log(picocolors.green("✔"), `Completed upload of remote file: '${ref}'`);
|
364
389
|
remoteFiles[sourcePath] = {
|
365
|
-
ref
|
390
|
+
ref,
|
366
391
|
metadata: fileSourceMetadata
|
367
392
|
};
|
368
393
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/cli",
|
3
3
|
"private": false,
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.74.0",
|
5
5
|
"description": "Val CLI tools",
|
6
6
|
"bin": {
|
7
7
|
"val": "./bin.js"
|
@@ -18,9 +18,9 @@
|
|
18
18
|
"typecheck": "tsc --noEmit"
|
19
19
|
},
|
20
20
|
"dependencies": {
|
21
|
-
"@valbuild/core": "~0.
|
22
|
-
"@valbuild/server": "~0.
|
23
|
-
"@valbuild/eslint-plugin": "~0.
|
21
|
+
"@valbuild/core": "~0.74.0",
|
22
|
+
"@valbuild/server": "~0.74.0",
|
23
|
+
"@valbuild/eslint-plugin": "~0.74.0",
|
24
24
|
"eslint": "^8.31.0",
|
25
25
|
"@inquirer/confirm": "^2.0.15",
|
26
26
|
"@inquirer/prompts": "^3.0.2",
|
package/src/validate.ts
CHANGED
@@ -23,7 +23,9 @@ import picocolors from "picocolors";
|
|
23
23
|
import { ESLint } from "eslint";
|
24
24
|
import fs from "fs/promises";
|
25
25
|
import { evalValConfigFile } from "./utils/evalValConfigFile";
|
26
|
+
import { getFileExt } from "./utils/getFileExt";
|
26
27
|
|
28
|
+
const textEncoder = new TextEncoder();
|
27
29
|
export async function validate({
|
28
30
|
root,
|
29
31
|
fix,
|
@@ -34,6 +36,8 @@ export async function validate({
|
|
34
36
|
noEslint?: boolean;
|
35
37
|
}) {
|
36
38
|
const valRemoteHost = process.env.VAL_REMOTE_HOST || DEFAULT_VAL_REMOTE_HOST;
|
39
|
+
const contentHostUrl =
|
40
|
+
process.env.VAL_CONTENT_URL || "https://content.val.build";
|
37
41
|
const projectRoot = root ? path.resolve(root) : process.cwd();
|
38
42
|
const eslint = new ESLint({
|
39
43
|
cwd: projectRoot,
|
@@ -352,12 +356,7 @@ export async function validate({
|
|
352
356
|
);
|
353
357
|
continue;
|
354
358
|
}
|
355
|
-
// TODO: parallelize
|
356
|
-
console.log(
|
357
|
-
picocolors.yellow("⚠"),
|
358
|
-
`Uploading remote file ${filePath}...`,
|
359
|
-
);
|
360
|
-
|
359
|
+
// TODO: parallelize uploading files
|
361
360
|
if (!resolvedRemoteFileAtSourcePath.schema) {
|
362
361
|
console.log(
|
363
362
|
picocolors.red("✘"),
|
@@ -420,6 +419,14 @@ export async function validate({
|
|
420
419
|
errors += 1;
|
421
420
|
continue;
|
422
421
|
}
|
422
|
+
if (!valConfigFile?.project) {
|
423
|
+
console.log(
|
424
|
+
picocolors.red("✘"),
|
425
|
+
`Could not get project. Check that your val.config has the 'project' field set, or set it using the VAL_PROJECT environment variable`,
|
426
|
+
);
|
427
|
+
errors += 1;
|
428
|
+
continue;
|
429
|
+
}
|
423
430
|
if (
|
424
431
|
resolveRemoteFileSchema.type !== "image" &&
|
425
432
|
resolveRemoteFileSchema.type !== "file"
|
@@ -465,32 +472,57 @@ export async function validate({
|
|
465
472
|
errors += 1;
|
466
473
|
continue;
|
467
474
|
}
|
468
|
-
|
469
|
-
|
470
|
-
|
475
|
+
|
476
|
+
const fileHash = Internal.remote.getFileHash(fileBuffer);
|
477
|
+
const coreVersion = Internal.VERSION.core || "unknown";
|
478
|
+
const fileExt = getFileExt(filePath);
|
479
|
+
const schema = resolveRemoteFileSchema as
|
480
|
+
| SerializedImageSchema
|
481
|
+
| SerializedFileSchema;
|
482
|
+
const metadata = fileSourceMetadata;
|
483
|
+
const ref = Internal.remote.createRemoteRef(valRemoteHost, {
|
471
484
|
publicProjectId,
|
485
|
+
coreVersion,
|
486
|
+
bucket,
|
487
|
+
validationHash: Internal.remote.getValidationHash(
|
488
|
+
coreVersion,
|
489
|
+
schema,
|
490
|
+
fileExt,
|
491
|
+
metadata,
|
492
|
+
fileHash,
|
493
|
+
textEncoder,
|
494
|
+
),
|
495
|
+
fileHash,
|
496
|
+
filePath: relativeFilePath,
|
497
|
+
});
|
498
|
+
console.log(
|
499
|
+
picocolors.yellow("⚠"),
|
500
|
+
`Uploading remote file: '${ref}'...`,
|
501
|
+
);
|
502
|
+
|
503
|
+
const remoteFileUpload = await uploadRemoteFile(
|
504
|
+
contentHostUrl,
|
505
|
+
valConfigFile.project,
|
472
506
|
bucket,
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
| SerializedImageSchema,
|
477
|
-
fileSourceMetadata,
|
507
|
+
fileHash,
|
508
|
+
fileExt,
|
509
|
+
fileBuffer,
|
478
510
|
{ pat },
|
479
511
|
);
|
480
512
|
if (!remoteFileUpload.success) {
|
481
513
|
console.log(
|
482
514
|
picocolors.red("✘"),
|
483
|
-
`
|
515
|
+
`Could not upload remote file: '${ref}'. Error: ${remoteFileUpload.error}`,
|
484
516
|
);
|
485
517
|
errors += 1;
|
486
518
|
continue;
|
487
519
|
}
|
488
520
|
console.log(
|
489
|
-
picocolors.
|
490
|
-
`
|
521
|
+
picocolors.green("✔"),
|
522
|
+
`Completed upload of remote file: '${ref}'`,
|
491
523
|
);
|
492
524
|
remoteFiles[sourcePath as SourcePath] = {
|
493
|
-
ref
|
525
|
+
ref,
|
494
526
|
metadata: fileSourceMetadata,
|
495
527
|
};
|
496
528
|
}
|