trainfabric 0.1.27 → 0.1.29
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.cjs +21 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8823,6 +8823,7 @@ var idPatterns = {
|
|
|
8823
8823
|
apiKey: /^key_[A-Za-z0-9_-]+$/,
|
|
8824
8824
|
dataset: /^ds_[A-Za-z0-9_-]+$/,
|
|
8825
8825
|
deployment: /^dep_[A-Za-z0-9_-]+$/,
|
|
8826
|
+
detection: /^det_[A-Za-z0-9_-]+$/,
|
|
8826
8827
|
model: /^mdl_[A-Za-z0-9_-]+$/,
|
|
8827
8828
|
org: /^org_[A-Za-z0-9_-]+$/,
|
|
8828
8829
|
pool: /^pool_[A-Za-z0-9_-]+$/,
|
|
@@ -8905,13 +8906,26 @@ function validateGitUrl(value) {
|
|
|
8905
8906
|
}
|
|
8906
8907
|
return value;
|
|
8907
8908
|
}
|
|
8909
|
+
function validateGitBranch(value) {
|
|
8910
|
+
const branch = String(value ?? "").trim();
|
|
8911
|
+
const invalidCharacterPattern = /[\x00-\x20~^:?*[\]\\]/;
|
|
8912
|
+
if (!branch || branch === "@" || branch.startsWith("-") || branch.startsWith("/") || branch.endsWith("/") || branch.endsWith(".") || branch.includes("//") || branch.includes("..") || branch.includes("@{") || invalidCharacterPattern.test(branch) || branch.split("/").some((part) => !part || part.startsWith(".") || part.endsWith(".lock"))) {
|
|
8913
|
+
throw new Error("Git branch is invalid. Use a valid git branch name, for example main or feature/train-run.");
|
|
8914
|
+
}
|
|
8915
|
+
return branch;
|
|
8916
|
+
}
|
|
8908
8917
|
function validateRepoPath(repoPath) {
|
|
8909
8918
|
const absolute = import_node_path2.default.resolve(repoPath);
|
|
8910
8919
|
const parsed = import_node_path2.default.parse(absolute);
|
|
8911
8920
|
if (absolute === parsed.root || absolute === import_node_os.default.homedir()) {
|
|
8912
8921
|
throw new Error(`Refusing to package unsafe repository path: ${repoPath}`);
|
|
8913
8922
|
}
|
|
8914
|
-
|
|
8923
|
+
let stat;
|
|
8924
|
+
try {
|
|
8925
|
+
stat = import_node_fs.default.statSync(absolute);
|
|
8926
|
+
} catch {
|
|
8927
|
+
throw new Error(`Repository path not found: ${repoPath}`);
|
|
8928
|
+
}
|
|
8915
8929
|
if (!stat.isDirectory()) {
|
|
8916
8930
|
throw new Error(`Repository path must be a directory: ${repoPath}`);
|
|
8917
8931
|
}
|
|
@@ -8921,6 +8935,9 @@ function buildSourceOptions(options) {
|
|
|
8921
8935
|
if (options.repo && options.git) {
|
|
8922
8936
|
throw new Error("Use either --repo or --git, not both.");
|
|
8923
8937
|
}
|
|
8938
|
+
if (options.branch && !options.git) {
|
|
8939
|
+
throw new Error("--branch only applies when --git is used.");
|
|
8940
|
+
}
|
|
8924
8941
|
if (options.repo) {
|
|
8925
8942
|
const repoPath = validateRepoPath(options.repo);
|
|
8926
8943
|
const files = collectRuntimeFiles(repoPath);
|
|
@@ -8937,7 +8954,7 @@ function buildSourceOptions(options) {
|
|
|
8937
8954
|
source: {
|
|
8938
8955
|
kind: "git",
|
|
8939
8956
|
repoUrl: validateGitUrl(options.git),
|
|
8940
|
-
branch: options.branch
|
|
8957
|
+
branch: options.branch === void 0 ? void 0 : validateGitBranch(options.branch)
|
|
8941
8958
|
}
|
|
8942
8959
|
};
|
|
8943
8960
|
}
|
|
@@ -9122,7 +9139,7 @@ function buildComputeSpec(options) {
|
|
|
9122
9139
|
|
|
9123
9140
|
// src/index.ts
|
|
9124
9141
|
var DEFAULT_TRAINFABRIC_API_URL2 = "https://api.trainfabric.com";
|
|
9125
|
-
var CLI_VERSION = "0.1.
|
|
9142
|
+
var CLI_VERSION = "0.1.29";
|
|
9126
9143
|
var CONFIG_DIR = import_node_path3.default.join(import_node_os2.default.homedir(), ".trainfabric");
|
|
9127
9144
|
var CONFIG_PATH = import_node_path3.default.join(CONFIG_DIR, "config.json");
|
|
9128
9145
|
var FALLBACK_SECRET_PATH = import_node_path3.default.join(CONFIG_DIR, "session.enc");
|
|
@@ -9806,7 +9823,7 @@ program2.command("runtime:build").option("--project <projectId>").requiredOption
|
|
|
9806
9823
|
printJson(
|
|
9807
9824
|
await createClient(config).runtime.build({
|
|
9808
9825
|
projectId: requireProjectId(options, config),
|
|
9809
|
-
detectionId: options.detection
|
|
9826
|
+
detectionId: normalizeId(options.detection, "detection", "Runtime detection ID")
|
|
9810
9827
|
})
|
|
9811
9828
|
);
|
|
9812
9829
|
});
|