diff --git a/actions/assemble-docs/dist/index.js b/actions/assemble-docs/dist/index.js index 4549620..46ff888 100644 --- a/actions/assemble-docs/dist/index.js +++ b/actions/assemble-docs/dist/index.js @@ -19056,6 +19056,7 @@ var require_dist = __commonJS({ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); var src_exports = {}; __export2(src_exports, { + absolutePath: () => absolutePath2, deleteFile: () => deleteFile2, exec: () => exec, generateRandomSuffix: () => generateRandomSuffix, @@ -19093,15 +19094,19 @@ var require_dist = __commonJS({ process.chdir(currentDir); } var import_node_fs = __toESM2(require("node:fs")); + var import_node_path2 = __toESM2(require("node:path")); function moveFile(src, dest) { import_node_fs.default.renameSync(src, dest); } - function deleteFile2(path2) { + function deleteFile2(filePath) { try { - import_node_fs.default.rmSync(path2); + import_node_fs.default.rmSync(filePath); } catch { } } + function absolutePath2(p) { + return p.startsWith("/") ? p : import_node_path2.default.join(process.cwd(), p); + } function gitAdd() { exec(`git add .`); } @@ -19226,10 +19231,11 @@ async function run() { const versionLabel = (0, import_action_utils2.getOptInput)("version_label", version2); const versionInTitle = (0, import_action_utils2.getOptInput)("version_in_title", ""); const targetDir = (0, import_action_utils2.getInput)("target_dir"); - const targetZipFile = import_node_path.default.join(process.cwd(), targetDir, `${version2}.zip`); + const absoluteAssetsDir = (0, import_action_utils2.absolutePath)(assetsDir); + const absoluteTargetDir = (0, import_action_utils2.absolutePath)(targetDir); + const targetZipFile = import_node_path.default.join(absoluteTargetDir, `${version2}.zip`); const targetVersionsJsonFile = import_node_path.default.join( - process.cwd(), - targetDir, + absoluteTargetDir, VERSIONS_JSON_FILE_NAME ); if (!isValidVersion(version2)) { @@ -19239,9 +19245,9 @@ async function run() { } core.info(`Cleaning up ${targetZipFile}`); (0, import_action_utils2.deleteFile)(targetZipFile); - core.info(`Zipping ${assetsDir} to ${targetZipFile}`); + core.info(`Zipping ${absoluteAssetsDir} to ${targetZipFile}`); (0, import_action_utils2.zip)({ - absoluteSrcPath: assetsDir, + absoluteSrcPath: absoluteAssetsDir, absoluteDestPath: targetZipFile }); if (isVersionListedInVersionsJson(version2)) { diff --git a/actions/assemble-docs/src/main.ts b/actions/assemble-docs/src/main.ts index 3ad45a2..aa29f03 100644 --- a/actions/assemble-docs/src/main.ts +++ b/actions/assemble-docs/src/main.ts @@ -1,6 +1,12 @@ import path from 'node:path'; import * as core from '@actions/core'; -import { deleteFile, getInput, getOptInput, zip } from '@dfinity/action-utils'; +import { + absolutePath, + deleteFile, + getInput, + getOptInput, + zip, +} from '@dfinity/action-utils'; import { upsertVersionsJson } from './upsert-versions-json'; import { ALLOWED_VERSIONS_MESSAGE, @@ -17,10 +23,12 @@ export async function run(): Promise { const versionLabel = getOptInput('version_label', version); const versionInTitle = getOptInput('version_in_title', ''); const targetDir = getInput('target_dir'); - const targetZipFile = path.join(process.cwd(), targetDir, `${version}.zip`); + + const absoluteAssetsDir = absolutePath(assetsDir); + const absoluteTargetDir = absolutePath(targetDir); + const targetZipFile = path.join(absoluteTargetDir, `${version}.zip`); const targetVersionsJsonFile = path.join( - process.cwd(), - targetDir, + absoluteTargetDir, VERSIONS_JSON_FILE_NAME, ); @@ -33,9 +41,9 @@ export async function run(): Promise { core.info(`Cleaning up ${targetZipFile}`); deleteFile(targetZipFile); - core.info(`Zipping ${assetsDir} to ${targetZipFile}`); + core.info(`Zipping ${absoluteAssetsDir} to ${targetZipFile}`); zip({ - absoluteSrcPath: assetsDir, + absoluteSrcPath: absoluteAssetsDir, absoluteDestPath: targetZipFile, }); diff --git a/actions/create-pr/dist/index.js b/actions/create-pr/dist/index.js index d08aa73..4d3085f 100644 --- a/actions/create-pr/dist/index.js +++ b/actions/create-pr/dist/index.js @@ -23135,6 +23135,7 @@ var require_dist = __commonJS({ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); var src_exports = {}; __export2(src_exports, { + absolutePath: () => absolutePath, deleteFile: () => deleteFile, exec: () => exec, generateRandomSuffix: () => generateRandomSuffix2, @@ -23172,15 +23173,19 @@ var require_dist = __commonJS({ process.chdir(currentDir); } var import_node_fs = __toESM2(require("node:fs")); + var import_node_path = __toESM2(require("node:path")); function moveFile(src, dest) { import_node_fs.default.renameSync(src, dest); } - function deleteFile(path) { + function deleteFile(filePath) { try { - import_node_fs.default.rmSync(path); + import_node_fs.default.rmSync(filePath); } catch { } } + function absolutePath(p) { + return p.startsWith("/") ? p : import_node_path.default.join(process.cwd(), p); + } function gitAdd2() { exec(`git add .`); } diff --git a/actions/extract-version/dist/index.js b/actions/extract-version/dist/index.js index 028a07e..7974bd8 100644 --- a/actions/extract-version/dist/index.js +++ b/actions/extract-version/dist/index.js @@ -19056,6 +19056,7 @@ var require_dist = __commonJS({ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); var src_exports = {}; __export2(src_exports, { + absolutePath: () => absolutePath, deleteFile: () => deleteFile, exec: () => exec2, generateRandomSuffix: () => generateRandomSuffix, @@ -19093,15 +19094,19 @@ var require_dist = __commonJS({ process.chdir(currentDir); } var import_node_fs2 = __toESM2(require("node:fs")); + var import_node_path2 = __toESM2(require("node:path")); function moveFile(src, dest) { import_node_fs2.default.renameSync(src, dest); } - function deleteFile(path2) { + function deleteFile(filePath) { try { - import_node_fs2.default.rmSync(path2); + import_node_fs2.default.rmSync(filePath); } catch { } } + function absolutePath(p) { + return p.startsWith("/") ? p : import_node_path2.default.join(process.cwd(), p); + } function gitAdd() { exec2(`git add .`); } diff --git a/actions/submit-docs/dist/index.js b/actions/submit-docs/dist/index.js index a958416..675192e 100644 --- a/actions/submit-docs/dist/index.js +++ b/actions/submit-docs/dist/index.js @@ -23135,6 +23135,7 @@ var require_dist = __commonJS({ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); var src_exports = {}; __export2(src_exports, { + absolutePath: () => absolutePath, deleteFile: () => deleteFile, exec: () => exec, generateRandomSuffix: () => generateRandomSuffix, @@ -23172,15 +23173,19 @@ var require_dist = __commonJS({ process.chdir(currentDir); } var import_node_fs = __toESM2(require("node:fs")); + var import_node_path = __toESM2(require("node:path")); function moveFile(src, dest) { import_node_fs.default.renameSync(src, dest); } - function deleteFile(path) { + function deleteFile(filePath) { try { - import_node_fs.default.rmSync(path); + import_node_fs.default.rmSync(filePath); } catch { } } + function absolutePath(p) { + return p.startsWith("/") ? p : import_node_path.default.join(process.cwd(), p); + } function gitAdd2() { exec(`git add .`); } diff --git a/lib/action-utils/src/fs.ts b/lib/action-utils/src/fs.ts index 7923473..d1c61ef 100644 --- a/lib/action-utils/src/fs.ts +++ b/lib/action-utils/src/fs.ts @@ -1,13 +1,18 @@ import fs from 'node:fs'; +import path from 'node:path'; export function moveFile(src: string, dest: string): void { fs.renameSync(src, dest); } -export function deleteFile(path: string): void { +export function deleteFile(filePath: string): void { try { - fs.rmSync(path); + fs.rmSync(filePath); } catch { // ignore if file does not exist } } + +export function absolutePath(p: string): string { + return p.startsWith('/') ? p : path.join(process.cwd(), p); +}