@tenderprompt/cli 0.1.20 → 0.1.21
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/dist/index.js +43 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
|
5
5
|
import os from 'node:os';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import { generateTenderAppEnvTypes, validateTenderApp, } from '@tenderprompt/tender-app-validator';
|
|
8
|
+
import { generateTenderAppEnvTypes, isForbiddenTenderAppRepoPath, isForbiddenTenderAppSecretPath, validateTenderApp, } from '@tenderprompt/tender-app-validator';
|
|
9
9
|
import { collectTenderAppFiles } from "./local-files.js";
|
|
10
10
|
const CLI_PACKAGE_NAME = '@tenderprompt/cli';
|
|
11
11
|
const UNKNOWN_CLI_VERSION = '0.0.0';
|
|
@@ -5865,6 +5865,30 @@ function readPreviewUrlFromJob(job) {
|
|
|
5865
5865
|
function readPublishedUrlFromJob(job) {
|
|
5866
5866
|
return readObjectString(job?.result, 'publishedUrl');
|
|
5867
5867
|
}
|
|
5868
|
+
function readReleaseGitRefFromResult(result) {
|
|
5869
|
+
const releaseGitRef = readObject(readObject(result)?.releaseGitRef);
|
|
5870
|
+
if (releaseGitRef?.type !== 'tag') {
|
|
5871
|
+
return null;
|
|
5872
|
+
}
|
|
5873
|
+
const tagName = readObjectString(releaseGitRef, 'name');
|
|
5874
|
+
const commitSha = readObjectString(releaseGitRef, 'commitSha');
|
|
5875
|
+
if (!tagName && !commitSha) {
|
|
5876
|
+
return null;
|
|
5877
|
+
}
|
|
5878
|
+
return {
|
|
5879
|
+
tagName,
|
|
5880
|
+
commitSha,
|
|
5881
|
+
};
|
|
5882
|
+
}
|
|
5883
|
+
function formatPublishResultLines(result) {
|
|
5884
|
+
const record = readObject(result);
|
|
5885
|
+
const releaseGitRef = readReleaseGitRefFromResult(result);
|
|
5886
|
+
return [
|
|
5887
|
+
...(readObjectString(record, 'publishedUrl') ? [`published_url: ${readObjectString(record, 'publishedUrl')}`] : []),
|
|
5888
|
+
...(releaseGitRef?.tagName ? [`release_tag: ${releaseGitRef.tagName}`] : []),
|
|
5889
|
+
...(releaseGitRef?.commitSha ? [`source_commit: ${releaseGitRef.commitSha}`] : []),
|
|
5890
|
+
];
|
|
5891
|
+
}
|
|
5868
5892
|
function normalizeContextFilePath(filePath) {
|
|
5869
5893
|
const normalized = path.posix.normalize(filePath.replaceAll('\\', '/')).replace(/^\/+/, '');
|
|
5870
5894
|
if (!normalized || normalized === '.' || normalized.startsWith('../') || normalized.includes('/../')) {
|
|
@@ -5872,6 +5896,9 @@ function normalizeContextFilePath(filePath) {
|
|
|
5872
5896
|
}
|
|
5873
5897
|
return normalized;
|
|
5874
5898
|
}
|
|
5899
|
+
function isForbiddenSourceExportPath(filePath) {
|
|
5900
|
+
return isForbiddenTenderAppRepoPath(filePath) || isForbiddenTenderAppSecretPath(filePath);
|
|
5901
|
+
}
|
|
5875
5902
|
function resolveContextOutputPath(root, relativePath) {
|
|
5876
5903
|
const absolutePath = path.resolve(root, relativePath);
|
|
5877
5904
|
const relativeFromRoot = path.relative(root, absolutePath);
|
|
@@ -5971,6 +5998,9 @@ async function collectArtifactWorkspaceSourceFiles(input) {
|
|
|
5971
5998
|
if (!normalizedPath) {
|
|
5972
5999
|
continue;
|
|
5973
6000
|
}
|
|
6001
|
+
if (isForbiddenSourceExportPath(normalizedPath)) {
|
|
6002
|
+
continue;
|
|
6003
|
+
}
|
|
5974
6004
|
if (entry.type === 'directory') {
|
|
5975
6005
|
queue.push(entry.path);
|
|
5976
6006
|
continue;
|
|
@@ -5996,7 +6026,11 @@ async function collectArtifactWorkspaceSourceFiles(input) {
|
|
|
5996
6026
|
async function planSourceFiles(input) {
|
|
5997
6027
|
const planned = [];
|
|
5998
6028
|
for (const file of input.files) {
|
|
5999
|
-
const
|
|
6029
|
+
const relativePath = normalizeContextFilePath(file.path);
|
|
6030
|
+
if (!relativePath || isForbiddenSourceExportPath(relativePath)) {
|
|
6031
|
+
continue;
|
|
6032
|
+
}
|
|
6033
|
+
const absolutePath = resolveContextOutputPath(input.root, relativePath);
|
|
6000
6034
|
if (!absolutePath) {
|
|
6001
6035
|
throw new Error(`Source file path escapes the target directory: ${file.path}`);
|
|
6002
6036
|
}
|
|
@@ -6012,7 +6046,7 @@ async function planSourceFiles(input) {
|
|
|
6012
6046
|
action = input.force ? 'overwrite' : 'conflict';
|
|
6013
6047
|
}
|
|
6014
6048
|
planned.push({
|
|
6015
|
-
path:
|
|
6049
|
+
path: relativePath,
|
|
6016
6050
|
absolutePath,
|
|
6017
6051
|
action,
|
|
6018
6052
|
content: file.content,
|
|
@@ -7717,7 +7751,12 @@ async function postLifecycle(input) {
|
|
|
7717
7751
|
input.io.stdout(JSON.stringify(result, null, 2));
|
|
7718
7752
|
}
|
|
7719
7753
|
else {
|
|
7720
|
-
input.io.stdout([
|
|
7754
|
+
input.io.stdout([
|
|
7755
|
+
`app_id: ${input.command.artifactId}`,
|
|
7756
|
+
`operation: ${result.operation}`,
|
|
7757
|
+
'status: completed',
|
|
7758
|
+
...(input.operation === 'publish' ? formatPublishResultLines(result.result) : []),
|
|
7759
|
+
].join('\n'));
|
|
7721
7760
|
}
|
|
7722
7761
|
return 0;
|
|
7723
7762
|
}
|