@shipstatic/ship 0.1.3 → 0.1.5
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/browser-files-E7BV45ED.js +2 -0
- package/dist/browser-files-ENFXWWBQ.browser.js +2 -0
- package/dist/chunk-6BOABYS2.browser.js +2 -0
- package/dist/chunk-6BOABYS2.browser.js.map +1 -0
- package/dist/chunk-6S6AGFLG.js +2 -0
- package/dist/chunk-VW3YZH4P.js +2 -0
- package/dist/chunk-VW3YZH4P.js.map +1 -0
- package/dist/{chunk-WJA55FEC.browser.js → chunk-X5GSJTFQ.browser.js} +2 -2
- package/dist/cli.cjs +2 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{path-6I7MXXVI.js → path-3A23JUQ3.js} +2 -2
- package/dist/{path-3OU57R5J.browser.js → path-LXKBQBOH.browser.js} +2 -2
- package/package.json +2 -1
- package/dist/browser-files-57AJ3XWD.js +0 -2
- package/dist/browser-files-DMOO6YMM.browser.js +0 -2
- package/dist/chunk-6KASX3WY.js +0 -2
- package/dist/chunk-OJ6FY5CZ.js +0 -2
- package/dist/chunk-OJ6FY5CZ.js.map +0 -1
- package/dist/chunk-Z566D7DF.browser.js +0 -2
- package/dist/chunk-Z566D7DF.browser.js.map +0 -1
- /package/dist/{browser-files-57AJ3XWD.js.map → browser-files-E7BV45ED.js.map} +0 -0
- /package/dist/{browser-files-DMOO6YMM.browser.js.map → browser-files-ENFXWWBQ.browser.js.map} +0 -0
- /package/dist/{chunk-6KASX3WY.js.map → chunk-6S6AGFLG.js.map} +0 -0
- /package/dist/{chunk-WJA55FEC.browser.js.map → chunk-X5GSJTFQ.browser.js.map} +0 -0
- /package/dist/{path-3OU57R5J.browser.js.map → path-3A23JUQ3.js.map} +0 -0
- /package/dist/{path-6I7MXXVI.js.map → path-LXKBQBOH.browser.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as o}from"./chunk-KBFFWP3K.browser.js";function m(e,s){if(!e||!Array.isArray(e)||e.length===0)return"";let a=e.filter(n=>n&&typeof n=="string");if(a.length===0)return"";let r=a.map(n=>{let t=n.replace(/\\/g,"/").replace(/^\/+/,"");return t.endsWith("/")?t:t+"/"});if(r.length===1)return r[0].slice(0,-1);let g=r.map(n=>n.split("/").filter(Boolean)),i=[],l=g[0];for(let n=0;n<l.length;n++){let t=l[n];if(g.every(c=>c.length>n&&c[n]===t))i.push(t);else break}return i.length===0?"":i.join("/")}function p(e){if(typeof o>"u")return m(e,"/");let s=o("path");return m(e,s.sep)}function h(e){return e.replace(/\\/g,"/")}function f(e){return e.replace(/\\/g,"/").replace(/^\/+/,"")}function d(e){return f(e)}export{m as a,p as b,h as c,f as d,d as e};
|
|
2
|
+
//# sourceMappingURL=chunk-6BOABYS2.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/path.ts"],"sourcesContent":["/**\n * @file Path helper utilities that work in both browser and Node.js environments.\n * Provides environment-agnostic path manipulation functions.\n */\n\n/**\n * Finds the common parent directory from an array of paths.\n * This function is the single shared implementation to be used by both browser and Node.js environments.\n * \n * @param paths - Array of paths to analyze for common parent directory.\n * @param separator - Path separator character (e.g., '/' for browser, path.sep for Node.js).\n * @returns The common parent directory path, or an empty string if none is found.\n */\nexport function findCommonParentDirectory(paths: string[], separator: string): string {\n // Validate input\n if (!paths || !Array.isArray(paths) || paths.length === 0) {\n return '';\n }\n \n // Filter out empty paths\n const validPaths = paths.filter(p => p && typeof p === 'string');\n \n if (validPaths.length === 0) {\n return '';\n }\n\n // Normalize paths to ensure consistent handling across environments\n // Convert all paths to use forward slashes regardless of input format\n const normalizedPaths = validPaths.map(p => {\n // Use the existing path normalization function to handle Windows and Unix paths\n const normalized = p.replace(/\\\\/g, '/').replace(/^\\/+/, '');\n // Add trailing slash for consistent segment comparison\n return normalized.endsWith('/') ? normalized : normalized + '/';\n });\n \n // Special case for single path: return the directory itself\n // This ensures we strip the directory name for single directory inputs\n if (normalizedPaths.length === 1) {\n const path = normalizedPaths[0];\n // For a single path, return the path itself (without trailing slash)\n return path.slice(0, -1); // Remove trailing slash\n }\n\n // For multiple paths: find the common prefix across all paths using segments\n // Split all paths into segments for proper path component comparison\n const pathSegments = normalizedPaths.map(p => p.split('/').filter(Boolean));\n \n // Find the common path segments across all paths\n const commonSegments = [];\n const firstPathSegments = pathSegments[0];\n \n for (let i = 0; i < firstPathSegments.length; i++) {\n const segment = firstPathSegments[i];\n // Check if this segment is common across all paths\n const isCommonSegment = pathSegments.every(segments => \n segments.length > i && segments[i] === segment\n );\n \n if (isCommonSegment) {\n commonSegments.push(segment);\n } else {\n break; // Stop at first non-matching segment\n }\n }\n \n // Reconstruct the common path\n if (commonSegments.length === 0) {\n return ''; // No common segments\n }\n \n // Return the common path (using the correct separator for the environment)\n return commonSegments.join('/');\n}\n\n/**\n * Simple helper to find common parent of absolute paths using the system path separator.\n * More declarative wrapper around findCommonParentDirectory for Node.js usage.\n * @param absolutePaths - Array of absolute file paths\n * @returns Common parent directory path or empty string if none found\n */\nexport function findCommonParent(absolutePaths: string[]): string {\n if (typeof require === 'undefined') {\n // Browser environment - use forward slash\n return findCommonParentDirectory(absolutePaths, '/');\n }\n \n // Node.js environment - use system separator\n const path = require('path');\n return findCommonParentDirectory(absolutePaths, path.sep);\n}\n\n\n/**\n * Converts backslashes to forward slashes for cross-platform compatibility.\n * Does not remove leading slashes (preserves absolute paths).\n * @param path - The path to normalize\n * @returns Path with forward slashes\n */\nexport function normalizeSlashes(path: string): string {\n return path.replace(/\\\\/g, '/');\n}\n\n/**\n * Normalizes a path for web usage by converting backslashes to forward slashes\n * and removing leading slashes.\n * @param path - The path to normalize\n * @returns Normalized path suitable for web deployment\n */\nexport function normalizeWebPath(path: string): string {\n return path.replace(/\\\\/g, '/').replace(/^\\/+/, '');\n}\n\n/**\n * Ensures a path is relative by normalizing it and removing any leading slashes.\n * @param path - The path to make relative\n * @returns Relative path suitable for web deployment\n */\nexport function ensureRelativePath(path: string): string {\n return normalizeWebPath(path);\n}\n"],"mappings":"gDAaO,SAASA,EAA0BC,EAAiBC,EAA2B,CAEpF,GAAI,CAACD,GAAS,CAAC,MAAM,QAAQA,CAAK,GAAKA,EAAM,SAAW,EACtD,MAAO,GAIT,IAAME,EAAaF,EAAM,OAAOG,GAAKA,GAAK,OAAOA,GAAM,QAAQ,EAE/D,GAAID,EAAW,SAAW,EACxB,MAAO,GAKT,IAAME,EAAkBF,EAAW,IAAIC,GAAK,CAE1C,IAAME,EAAaF,EAAE,QAAQ,MAAO,GAAG,EAAE,QAAQ,OAAQ,EAAE,EAE3D,OAAOE,EAAW,SAAS,GAAG,EAAIA,EAAaA,EAAa,GAC9D,CAAC,EAID,GAAID,EAAgB,SAAW,EAG7B,OAFaA,EAAgB,CAAC,EAElB,MAAM,EAAG,EAAE,EAKzB,IAAME,EAAeF,EAAgB,IAAID,GAAKA,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,CAAC,EAGpEI,EAAiB,CAAC,EAClBC,EAAoBF,EAAa,CAAC,EAExC,QAASG,EAAI,EAAGA,EAAID,EAAkB,OAAQC,IAAK,CACjD,IAAMC,EAAUF,EAAkBC,CAAC,EAMnC,GAJwBH,EAAa,MAAMK,GACzCA,EAAS,OAASF,GAAKE,EAASF,CAAC,IAAMC,CACzC,EAGEH,EAAe,KAAKG,CAAO,MAE3B,MAEJ,CAGA,OAAIH,EAAe,SAAW,EACrB,GAIFA,EAAe,KAAK,GAAG,CAChC,CAQO,SAASK,EAAiBC,EAAiC,CAChE,GAAI,OAAOC,EAAY,IAErB,OAAOf,EAA0Bc,EAAe,GAAG,EAIrD,IAAME,EAAO,EAAQ,MAAM,EAC3B,OAAOhB,EAA0Bc,EAAeE,EAAK,GAAG,CAC1D,CASO,SAASC,EAAiBD,EAAsB,CACrD,OAAOA,EAAK,QAAQ,MAAO,GAAG,CAChC,CAQO,SAASE,EAAiBF,EAAsB,CACrD,OAAOA,EAAK,QAAQ,MAAO,GAAG,EAAE,QAAQ,OAAQ,EAAE,CACpD,CAOO,SAASG,EAAmBH,EAAsB,CACvD,OAAOE,EAAiBF,CAAI,CAC9B","names":["findCommonParentDirectory","paths","separator","validPaths","p","normalizedPaths","normalized","pathSegments","commonSegments","firstPathSegments","i","segment","segments","findCommonParent","absolutePaths","__require","path","normalizeSlashes","normalizeWebPath","ensureRelativePath"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as v,h as w}from"./chunk-VW3YZH4P.js";var g=null;function S(e){g=e}function b(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function d(){return g||b()}import{ShipError as u}from"@shipstatic/types";async function E(e){let n=(await import("spark-md5")).default;return new Promise((o,s)=>{let l=Math.ceil(e.size/2097152),t=0,c=new n.ArrayBuffer,m=new FileReader,p=()=>{let f=t*2097152,r=Math.min(f+2097152,e.size);m.readAsArrayBuffer(e.slice(f,r))};m.onload=f=>{let r=f.target?.result;if(!r){s(u.business("Failed to read file chunk"));return}c.append(r),t++,t<l?p():o({md5:c.end()})},m.onerror=()=>{s(u.business("Failed to calculate MD5: FileReader error"))},p()})}async function P(e){let n=await import("crypto");if(Buffer.isBuffer(e)){let s=n.createHash("md5");return s.update(e),{md5:s.digest("hex")}}let o=await import("fs");return new Promise((s,a)=>{let l=n.createHash("md5"),t=o.createReadStream(e);t.on("error",c=>a(u.business(`Failed to read file for MD5: ${c.message}`))),t.on("data",c=>l.update(c)),t.on("end",()=>s({md5:l.digest("hex")}))})}async function y(e){let n=d();if(n==="browser"){if(!(e instanceof Blob))throw u.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return E(e)}if(n==="node"){if(!(Buffer.isBuffer(e)||typeof e=="string"))throw u.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return P(e)}throw u.business("Unknown or unsupported execution environment for MD5 calculation.")}import{ShipError as B}from"@shipstatic/types";import{isJunk as D}from"junk";var k=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"];function x(e){return!e||e.length===0?[]:e.filter(n=>{if(!n)return!1;let o=n.replace(/\\/g,"/").split("/").filter(Boolean);if(o.length===0)return!0;let s=o[o.length-1];if(D(s))return!1;let a=o.slice(0,-1);for(let l of a)if(k.some(t=>l.toLowerCase()===t.toLowerCase()))return!1;return!0})}async function W(e,n={}){if(d()!=="browser")throw B.business("processFilesForBrowser can only be called in a browser environment.");let{explicitBaseDirInput:o,stripCommonPrefix:s}=n,a=[],l=Array.isArray(e)?e:Array.from(e),t="";s?t=F(e):o&&(t=o);for(let r of l){let i=r.webkitRelativePath||r.name;if(t){i=w(i);let h=t.endsWith("/")?t:`${t}/`;(i===t||i===h||i.startsWith(h))&&(i=i.substring(h.length))}i=w(i),a.push({file:r,relativePath:i})}let c=a.map(r=>r.relativePath),m=x(c),p=new Set(m),f=[];for(let r of a){if(!p.has(r.relativePath)||r.file.size===0)continue;let{md5:i}=await y(r.file);f.push({content:r.file,path:r.relativePath,size:r.file.size,md5:i})}return f}function F(e){if(d()!=="browser")throw B.business("findBrowserCommonParentDirectory can only be called in a browser environment.");if(!e||e.length===0)return"";let n=Array.from(e).map(o=>o.webkitRelativePath);return n.some(o=>!o)?"":v(n,"/")}export{S as a,d as b,y as c,x as d,W as e,F as f};
|
|
2
|
+
//# sourceMappingURL=chunk-6S6AGFLG.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var p=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var f=e=>{throw TypeError(e)};var g=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var m=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of d(n))!y.call(e,i)&&i!==t&&p(e,i,{get:()=>n[i],enumerable:!(o=h(n,i))||o.enumerable});return e},z=(e,n,t)=>(m(e,n,"default"),t&&m(t,n,"default"));var P=(e,n,t)=>n.has(e)||f("Cannot "+t);var C=(e,n,t)=>n.has(e)?f("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(e):n.set(e,t);var v=(e,n,t)=>(P(e,n,"access private method"),t);function u(e,n){if(!e||!Array.isArray(e)||e.length===0)return"";let t=e.filter(r=>r&&typeof r=="string");if(t.length===0)return"";let o=t.map(r=>{let s=r.replace(/\\/g,"/").replace(/^\/+/,"");return s.endsWith("/")?s:s+"/"});if(o.length===1)return o[0].slice(0,-1);let i=o.map(r=>r.split("/").filter(Boolean)),a=[],l=i[0];for(let r=0;r<l.length;r++){let s=l[r];if(i.every(c=>c.length>r&&c[r]===s))a.push(s);else break}return a.length===0?"":a.join("/")}function A(e){if(typeof g>"u")return u(e,"/");let n=g("path");return u(e,n.sep)}function W(e){return e.replace(/\\/g,"/")}function S(e){return e.replace(/\\/g,"/").replace(/^\/+/,"")}function b(e){return S(e)}export{g as a,z as b,C as c,v as d,u as e,A as f,W as g,S as h,b as i};
|
|
2
|
+
//# sourceMappingURL=chunk-VW3YZH4P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/path.ts"],"sourcesContent":["/**\n * @file Path helper utilities that work in both browser and Node.js environments.\n * Provides environment-agnostic path manipulation functions.\n */\n\n/**\n * Finds the common parent directory from an array of paths.\n * This function is the single shared implementation to be used by both browser and Node.js environments.\n * \n * @param paths - Array of paths to analyze for common parent directory.\n * @param separator - Path separator character (e.g., '/' for browser, path.sep for Node.js).\n * @returns The common parent directory path, or an empty string if none is found.\n */\nexport function findCommonParentDirectory(paths: string[], separator: string): string {\n // Validate input\n if (!paths || !Array.isArray(paths) || paths.length === 0) {\n return '';\n }\n \n // Filter out empty paths\n const validPaths = paths.filter(p => p && typeof p === 'string');\n \n if (validPaths.length === 0) {\n return '';\n }\n\n // Normalize paths to ensure consistent handling across environments\n // Convert all paths to use forward slashes regardless of input format\n const normalizedPaths = validPaths.map(p => {\n // Use the existing path normalization function to handle Windows and Unix paths\n const normalized = p.replace(/\\\\/g, '/').replace(/^\\/+/, '');\n // Add trailing slash for consistent segment comparison\n return normalized.endsWith('/') ? normalized : normalized + '/';\n });\n \n // Special case for single path: return the directory itself\n // This ensures we strip the directory name for single directory inputs\n if (normalizedPaths.length === 1) {\n const path = normalizedPaths[0];\n // For a single path, return the path itself (without trailing slash)\n return path.slice(0, -1); // Remove trailing slash\n }\n\n // For multiple paths: find the common prefix across all paths using segments\n // Split all paths into segments for proper path component comparison\n const pathSegments = normalizedPaths.map(p => p.split('/').filter(Boolean));\n \n // Find the common path segments across all paths\n const commonSegments = [];\n const firstPathSegments = pathSegments[0];\n \n for (let i = 0; i < firstPathSegments.length; i++) {\n const segment = firstPathSegments[i];\n // Check if this segment is common across all paths\n const isCommonSegment = pathSegments.every(segments => \n segments.length > i && segments[i] === segment\n );\n \n if (isCommonSegment) {\n commonSegments.push(segment);\n } else {\n break; // Stop at first non-matching segment\n }\n }\n \n // Reconstruct the common path\n if (commonSegments.length === 0) {\n return ''; // No common segments\n }\n \n // Return the common path (using the correct separator for the environment)\n return commonSegments.join('/');\n}\n\n/**\n * Simple helper to find common parent of absolute paths using the system path separator.\n * More declarative wrapper around findCommonParentDirectory for Node.js usage.\n * @param absolutePaths - Array of absolute file paths\n * @returns Common parent directory path or empty string if none found\n */\nexport function findCommonParent(absolutePaths: string[]): string {\n if (typeof require === 'undefined') {\n // Browser environment - use forward slash\n return findCommonParentDirectory(absolutePaths, '/');\n }\n \n // Node.js environment - use system separator\n const path = require('path');\n return findCommonParentDirectory(absolutePaths, path.sep);\n}\n\n\n/**\n * Converts backslashes to forward slashes for cross-platform compatibility.\n * Does not remove leading slashes (preserves absolute paths).\n * @param path - The path to normalize\n * @returns Path with forward slashes\n */\nexport function normalizeSlashes(path: string): string {\n return path.replace(/\\\\/g, '/');\n}\n\n/**\n * Normalizes a path for web usage by converting backslashes to forward slashes\n * and removing leading slashes.\n * @param path - The path to normalize\n * @returns Normalized path suitable for web deployment\n */\nexport function normalizeWebPath(path: string): string {\n return path.replace(/\\\\/g, '/').replace(/^\\/+/, '');\n}\n\n/**\n * Ensures a path is relative by normalizing it and removing any leading slashes.\n * @param path - The path to make relative\n * @returns Relative path suitable for web deployment\n */\nexport function ensureRelativePath(path: string): string {\n return normalizeWebPath(path);\n}\n"],"mappings":"i1BAaO,SAASA,EAA0BC,EAAiBC,EAA2B,CAEpF,GAAI,CAACD,GAAS,CAAC,MAAM,QAAQA,CAAK,GAAKA,EAAM,SAAW,EACtD,MAAO,GAIT,IAAME,EAAaF,EAAM,OAAOG,GAAKA,GAAK,OAAOA,GAAM,QAAQ,EAE/D,GAAID,EAAW,SAAW,EACxB,MAAO,GAKT,IAAME,EAAkBF,EAAW,IAAIC,GAAK,CAE1C,IAAME,EAAaF,EAAE,QAAQ,MAAO,GAAG,EAAE,QAAQ,OAAQ,EAAE,EAE3D,OAAOE,EAAW,SAAS,GAAG,EAAIA,EAAaA,EAAa,GAC9D,CAAC,EAID,GAAID,EAAgB,SAAW,EAG7B,OAFaA,EAAgB,CAAC,EAElB,MAAM,EAAG,EAAE,EAKzB,IAAME,EAAeF,EAAgB,IAAID,GAAKA,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,CAAC,EAGpEI,EAAiB,CAAC,EAClBC,EAAoBF,EAAa,CAAC,EAExC,QAASG,EAAI,EAAGA,EAAID,EAAkB,OAAQC,IAAK,CACjD,IAAMC,EAAUF,EAAkBC,CAAC,EAMnC,GAJwBH,EAAa,MAAMK,GACzCA,EAAS,OAASF,GAAKE,EAASF,CAAC,IAAMC,CACzC,EAGEH,EAAe,KAAKG,CAAO,MAE3B,MAEJ,CAGA,OAAIH,EAAe,SAAW,EACrB,GAIFA,EAAe,KAAK,GAAG,CAChC,CAQO,SAASK,EAAiBC,EAAiC,CAChE,GAAI,OAAOC,EAAY,IAErB,OAAOf,EAA0Bc,EAAe,GAAG,EAIrD,IAAME,EAAO,EAAQ,MAAM,EAC3B,OAAOhB,EAA0Bc,EAAeE,EAAK,GAAG,CAC1D,CASO,SAASC,EAAiBD,EAAsB,CACrD,OAAOA,EAAK,QAAQ,MAAO,GAAG,CAChC,CAQO,SAASE,EAAiBF,EAAsB,CACrD,OAAOA,EAAK,QAAQ,MAAO,GAAG,EAAE,QAAQ,OAAQ,EAAE,CACpD,CAOO,SAASG,EAAmBH,EAAsB,CACvD,OAAOE,EAAiBF,CAAI,CAC9B","names":["findCommonParentDirectory","paths","separator","validPaths","p","normalizedPaths","normalized","pathSegments","commonSegments","firstPathSegments","i","segment","segments","findCommonParent","absolutePaths","__require","path","normalizeSlashes","normalizeWebPath","ensureRelativePath"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as v,d as w}from"./chunk-6BOABYS2.browser.js";var g=null;function R(e){g=e}function B(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function p(){return g||B()}import{ShipError as f}from"@shipstatic/types";async function k(e){let n=(await import("./spark-md5-DLLZAUJQ.browser.js")).default;return new Promise((o,s)=>{let c=Math.ceil(e.size/2097152),t=0,l=new n.ArrayBuffer,m=new FileReader,d=()=>{let u=t*2097152,r=Math.min(u+2097152,e.size);m.readAsArrayBuffer(e.slice(u,r))};m.onload=u=>{let r=u.target?.result;if(!r){s(f.business("Failed to read file chunk"));return}l.append(r),t++,t<c?d():o({md5:l.end()})},m.onerror=()=>{s(f.business("Failed to calculate MD5: FileReader error"))},d()})}async function E(e){let n=await import("crypto");if(Buffer.isBuffer(e)){let s=n.createHash("md5");return s.update(e),{md5:s.digest("hex")}}let o=await import("fs");return new Promise((s,a)=>{let c=n.createHash("md5"),t=o.createReadStream(e);t.on("error",l=>a(f.business(`Failed to read file for MD5: ${l.message}`))),t.on("data",l=>c.update(l)),t.on("end",()=>s({md5:c.digest("hex")}))})}async function x(e){let n=p();if(n==="browser"){if(!(e instanceof Blob))throw f.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return k(e)}if(n==="node"){if(!(Buffer.isBuffer(e)||typeof e=="string"))throw f.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return E(e)}throw f.business("Unknown or unsupported execution environment for MD5 calculation.")}import{ShipError as D}from"@shipstatic/types";var S=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],P=new RegExp(S.join("|"));function b(e){return P.test(e)}var F=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"];function y(e){return!e||e.length===0?[]:e.filter(n=>{if(!n)return!1;let o=n.replace(/\\/g,"/").split("/").filter(Boolean);if(o.length===0)return!0;let s=o[o.length-1];if(b(s))return!1;let a=o.slice(0,-1);for(let c of a)if(F.some(t=>c.toLowerCase()===t.toLowerCase()))return!1;return!0})}async function W(e,n={}){if(p()!=="browser")throw D.business("processFilesForBrowser can only be called in a browser environment.");let{explicitBaseDirInput:o,stripCommonPrefix:s}=n,a=[],c=Array.isArray(e)?e:Array.from(e),t="";s?t=M(e):o&&(t=o);for(let r of c){let i=r.webkitRelativePath||r.name;if(t){i=w(i);let h=t.endsWith("/")?t:`${t}/`;(i===t||i===h||i.startsWith(h))&&(i=i.substring(h.length))}i=w(i),a.push({file:r,relativePath:i})}let l=a.map(r=>r.relativePath),m=y(l),d=new Set(m),u=[];for(let r of a){if(!d.has(r.relativePath)||r.file.size===0)continue;let{md5:i}=await x(r.file);u.push({content:r.file,path:r.relativePath,size:r.file.size,md5:i})}return u}function M(e){if(p()!=="browser")throw D.business("findBrowserCommonParentDirectory can only be called in a browser environment.");if(!e||e.length===0)return"";let n=Array.from(e).map(o=>o.webkitRelativePath);return n.some(o=>!o)?"":v(n,"/")}export{R as a,p as b,x as c,y as d,W as e,M as f};
|
|
2
|
+
//# sourceMappingURL=chunk-X5GSJTFQ.browser.js.map
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Je=Object.create;var Q=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ye=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var pe=e=>{throw TypeError(e)};var R=(e,t)=>()=>(e&&(t=e(e=0)),t);var me=(e,t)=>{for(var o in t)Q(e,o,{get:t[o],enumerable:!0})},Z=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ve(t))!Xe.call(e,i)&&i!==o&&Q(e,i,{get:()=>t[i],enumerable:!(n=We(t,i))||n.enumerable});return e},fe=(e,t,o)=>(Z(e,t,"default"),o&&Z(o,t,"default")),F=(e,t,o)=>(o=e!=null?Je(Ye(e)):{},Z(t||!e||!e.__esModule?Q(o,"default",{value:e,enumerable:!0}):o,e));var Ze=(e,t,o)=>t.has(e)||pe("Cannot "+o);var ue=(e,t,o)=>t.has(e)?pe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,o);var f=(e,t,o)=>(Ze(e,t,"access private method"),o);function Qe(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function h(){return ye||Qe()}var ye,ee=R(()=>{"use strict";ye=null});var A=R(()=>{"use strict";ee()});async function at(e){let t=(await import("spark-md5")).default;return new Promise((o,n)=>{let s=Math.ceil(e.size/2097152),r=0,l=new t.ArrayBuffer,u=new FileReader,c=()=>{let p=r*2097152,m=Math.min(p+2097152,e.size);u.readAsArrayBuffer(e.slice(p,m))};u.onload=p=>{let m=p.target?.result;if(!m){n(I.ShipError.business("Failed to read file chunk"));return}l.append(m),r++,r<s?c():o({md5:l.end()})},u.onerror=()=>{n(I.ShipError.business("Failed to calculate MD5: FileReader error"))},c()})}async function ct(e){let t=await import("crypto");if(Buffer.isBuffer(e)){let n=t.createHash("md5");return n.update(e),{md5:n.digest("hex")}}let o=await import("fs");return new Promise((n,i)=>{let s=t.createHash("md5"),r=o.createReadStream(e);r.on("error",l=>i(I.ShipError.business(`Failed to read file for MD5: ${l.message}`))),r.on("data",l=>s.update(l)),r.on("end",()=>n({md5:s.digest("hex")}))})}async function j(e){let t=h();if(t==="browser"){if(!(e instanceof Blob))throw I.ShipError.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return at(e)}if(t==="node"){if(!(Buffer.isBuffer(e)||typeof e=="string"))throw I.ShipError.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return ct(e)}throw I.ShipError.business("Unknown or unsupported execution environment for MD5 calculation.")}var I,ie=R(()=>{"use strict";ee();I=require("@shipstatic/types")});function H(e){return!e||e.length===0?[]:e.filter(t=>{if(!t)return!1;let o=t.replace(/\\/g,"/").split("/").filter(Boolean);if(o.length===0)return!0;let n=o[o.length-1];if((0,Ee.isJunk)(n))return!1;let i=o.slice(0,-1);for(let s of i)if(lt.some(r=>s.toLowerCase()===r.toLowerCase()))return!1;return!0})}var Ee,lt,se=R(()=>{"use strict";Ee=require("junk"),lt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});var $e={};me($e,{ensureRelativePath:()=>ft,findCommonParent:()=>pt,findCommonParentDirectory:()=>k,normalizeSlashes:()=>mt,normalizeWebPath:()=>L});function k(e,t){if(!e||!Array.isArray(e)||e.length===0)return"";let o=e.filter(c=>c&&typeof c=="string"&&c.includes(t));if(o.length===0)return"";if(o.length===1){let c=o[0],p=c.lastIndexOf(t);return p>-1?c.substring(0,p):""}let n=[...o].sort(),i=n[0],s=n[n.length-1],r=0;for(;r<i.length&&r<s.length&&i[r]===s[r];)r++;let l=i.substring(0,r);if(l.endsWith(t))return l.slice(0,-1);let u=l.lastIndexOf(t);return u>-1?l.substring(0,u):""}function pt(e){if(typeof require>"u")return k(e,"/");let t=require("path");return k(e,t.sep)}function mt(e){return e.replace(/\\/g,"/")}function L(e){return e.replace(/\\/g,"/").replace(/^\/+/,"")}function ft(e){return L(e)}var ae=R(()=>{"use strict"});async function G(e,t={}){if(h()!=="browser")throw ce.ShipError.business("processFilesForBrowser can only be called in a browser environment.");let{explicitBaseDirInput:o,stripCommonPrefix:n}=t,i=[],s=Array.isArray(e)?e:Array.from(e),r="";n?r=le(e):o&&(r=o);for(let m of s){let y=m.webkitRelativePath||m.name;if(r){y=L(y);let d=r.endsWith("/")?r:`${r}/`;(y===r||y===d||y.startsWith(d))&&(y=y.substring(d.length))}y=L(y),i.push({file:m,relativePath:y})}let l=i.map(m=>m.relativePath),u=H(l),c=new Set(u),p=[];for(let m of i){if(!c.has(m.relativePath)||m.file.size===0)continue;let{md5:y}=await j(m.file);p.push({content:m.file,path:m.relativePath,size:m.file.size,md5:y})}return p}function le(e){if(h()!=="browser")throw ce.ShipError.business("findBrowserCommonParentDirectory can only be called in a browser environment.");if(!e||e.length===0)return"";let t=Array.from(e).map(o=>o.webkitRelativePath);return t.some(o=>!o)?"":k(t,"/")}var ce,Oe=R(()=>{"use strict";A();ie();ce=require("@shipstatic/types");ae();se()});var Te={};me(Te,{findBrowserCommonParentDirectory:()=>le,processFilesForBrowser:()=>G});var q=R(()=>{"use strict";Oe()});var je=require("commander");A();var O=require("zod"),he=require("cosmiconfig");var E={};fe(E,require("@shipstatic/types"));A();var B="https://api.shipstatic.com";var de="ship",et=O.z.object({apiUrl:O.z.string().url().optional(),apiKey:O.z.string().optional()}).strict();function ge(e){try{return et.parse(e)}catch(t){if(t instanceof O.z.ZodError){let o=t.issues[0],n=o.path.length>0?` at ${o.path.join(".")}`:"";throw E.ShipError.config(`Configuration validation failed${n}: ${o.message}`)}throw E.ShipError.config("Configuration validation failed")}}function tt(){try{let t=(0,he.cosmiconfigSync)(de,{searchPlaces:[`.${de}rc`,"package.json"]}).search();if(t&&!t.isEmpty&&t.config)return ge(t.config)}catch(e){if(e instanceof E.ShipError)throw e}return{}}function we(){if(h()!=="node")return{};let e={apiUrl:process.env.SHIP_API_URL,apiKey:process.env.SHIP_API_KEY},t=tt(),o={apiUrl:e.apiUrl??t.apiUrl,apiKey:e.apiKey??t.apiKey};return ge(o)}function Pe(e={},t={}){let o={apiUrl:e.apiUrl||t.apiUrl||B,apiKey:e.apiKey!==void 0?e.apiKey:t.apiKey};return o.apiKey!==void 0?{apiUrl:o.apiUrl,apiKey:o.apiKey}:{apiUrl:o.apiUrl}}function xe(e={},t){let o={...e};return o.onProgress===void 0&&t.onProgress!==void 0&&(o.onProgress=t.onProgress),o.onProgressStats===void 0&&t.onProgressStats!==void 0&&(o.onProgressStats=t.onProgressStats),o.maxConcurrency===void 0&&t.maxConcurrentDeploys!==void 0&&(o.maxConcurrency=t.maxConcurrentDeploys),o.timeout===void 0&&t.timeout!==void 0&&(o.timeout=t.timeout),o.apiKey===void 0&&t.apiKey!==void 0&&(o.apiKey=t.apiKey),o.apiUrl===void 0&&t.apiUrl!==void 0&&(o.apiUrl=t.apiUrl),o}var M=F(require("mime-types"),1),g=require("@shipstatic/types");A();var N="/deployments",ot="/ping",_="/aliases",nt="/config",it="/account";function st(e){return typeof e=="string"?M.lookup(e)||"application/octet-stream":M.lookup(e.name)||e.type||"application/octet-stream"}async function rt(e){let t=[];for await(let o of e)t.push(o);return t}var a,be,te,P,ve,Fe,Se,Ce,oe,z,K=class{constructor(t){ue(this,a);this.apiUrl=t.apiUrl||B,this.apiKey=t.apiKey??""}async ping(){return(await f(this,a,P).call(this,`${this.apiUrl}${ot}`,{method:"GET"},"Ping"))?.success||!1}async getConfig(){return await f(this,a,P).call(this,`${this.apiUrl}${nt}`,{method:"GET"},"Config")}async deploy(t,o={}){f(this,a,ve).call(this,t);let{apiUrl:n=this.apiUrl,signal:i}=o;try{let{requestBody:s,requestHeaders:r}=await f(this,a,Fe).call(this,t),l={method:"POST",body:s,headers:r,signal:i||null},u=await f(this,a,te).call(this,`${n}${N}`,l,"Deploy");return u.ok||await f(this,a,oe).call(this,u,"Deploy"),await u.json()}catch(s){throw s instanceof g.ShipError?s:(f(this,a,z).call(this,s,"Deploy"),g.ShipError.business("An unexpected error occurred and was not handled."))}}async listDeployments(){return await f(this,a,P).call(this,`${this.apiUrl}${N}`,{method:"GET"},"List Deployments")}async getDeployment(t){return await f(this,a,P).call(this,`${this.apiUrl}${N}/${t}`,{method:"GET"},"Get Deployment")}async removeDeployment(t){await f(this,a,P).call(this,`${this.apiUrl}${N}/${t}`,{method:"DELETE"},"Remove Deployment")}async setAlias(t,o){return await f(this,a,P).call(this,`${this.apiUrl}${_}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({deploymentId:o})},"Set Alias")}async getAlias(t){return await f(this,a,P).call(this,`${this.apiUrl}${_}/${encodeURIComponent(t)}`,{method:"GET"},"Get Alias")}async listAliases(){return await f(this,a,P).call(this,`${this.apiUrl}${_}`,{method:"GET"},"List Aliases")}async removeAlias(t){await f(this,a,P).call(this,`${this.apiUrl}${_}/${encodeURIComponent(t)}`,{method:"DELETE"},"Remove Alias")}async getAccount(){return await f(this,a,P).call(this,`${this.apiUrl}${it}`,{method:"GET"},"Get Account")}async createApiKey(){return await f(this,a,P).call(this,`${this.apiUrl}/key`,{method:"POST"},"Create API Key")}};a=new WeakSet,be=function(t={}){let o={...t};return this.apiKey&&(o.Authorization=`Bearer ${this.apiKey}`),o},te=async function(t,o={},n){let i=f(this,a,be).call(this,o.headers),s={...o,headers:i,credentials:h()==="browser"?"include":"same-origin"};try{return await fetch(t,s)}catch(r){throw f(this,a,z).call(this,r,n),r}},P=async function(t,o={},n){try{let i=await f(this,a,te).call(this,t,o,n);return i.ok||await f(this,a,oe).call(this,i,n),i.headers.get("Content-Length")==="0"||i.status===204?void 0:await i.json()}catch(i){throw i instanceof g.ShipError||f(this,a,z).call(this,i,n),i}},ve=function(t){if(!t.length)throw g.ShipError.business("No files to deploy.");for(let o of t)if(!o.md5)throw g.ShipError.file(`MD5 checksum missing for file: ${o.path}`,o.path)},Fe=async function(t){let o,n={};if(h()==="browser")o=f(this,a,Se).call(this,t);else if(h()==="node"){let{body:i,headers:s}=await f(this,a,Ce).call(this,t);o=i,n=s}else throw g.ShipError.business("Unknown or unsupported execution environment");return{requestBody:o,requestHeaders:n}},Se=function(t){let o=new FormData,n=[];for(let i=0;i<t.length;i++){let s=t[i],r;if(s.content instanceof File||s.content instanceof Blob)r=s.content;else throw g.ShipError.file(`Unsupported file.content type for browser FormData: ${s.path}`,s.path);let l=st(r instanceof File?r:s.path),u=new File([r],s.path,{type:l});o.append("files[]",u),n.push(s.md5)}return o.append("checksums",JSON.stringify(n)),o},Ce=async function(t){let{FormData:o,File:n}=await import("formdata-node"),{FormDataEncoder:i}=await import("form-data-encoder"),s=await import("path"),r=new o,l=[];for(let y=0;y<t.length;y++){let d=t[y],U=M.lookup(d.path)||"application/octet-stream",X;if(Buffer.isBuffer(d.content))X=new n([d.content],s.basename(d.path),{type:U});else if(typeof Blob<"u"&&d.content instanceof Blob)X=new n([d.content],s.basename(d.path),{type:U});else throw g.ShipError.file(`Unsupported file.content type for Node.js FormData: ${d.path}`,d.path);let qe=d.path.startsWith("/")?d.path:"/"+d.path;r.append("files[]",X,qe),l.push(d.md5)}r.append("checksums",JSON.stringify(l));let u=new i(r),c=await rt(u.encode()),p=Buffer.concat(c.map(y=>Buffer.from(y))),m={"Content-Type":u.contentType,"Content-Length":Buffer.byteLength(p).toString()};return{body:p,headers:m}},oe=async function(t,o){let n={};try{let i=t.headers.get("content-type");i&&i.includes("application/json")?n=await t.json():n={message:await t.text()}}catch{n={message:"Failed to parse error response"}}if(n.error||n.code||n.message){let i=n.message||n.error||`${o} failed due to API error`;throw g.ShipError.api(i,t.status,n.code,n)}throw g.ShipError.api(`${o} failed due to API error`,t.status,void 0,n)},z=function(t,o){throw t.name==="AbortError"?g.ShipError.cancelled(`${o} operation was cancelled.`):t instanceof TypeError&&t.message.includes("fetch")?g.ShipError.network(`${o} failed due to network error: ${t.message}`,t):t instanceof g.ShipError?t:g.ShipError.business(`An unexpected error occurred during ${o}: ${t.message||"Unknown error"}`)};var Me=require("@shipstatic/types");var De=require("@shipstatic/types"),ne=null;function Ae(e){ne=e}function T(){if(ne===null)throw De.ShipError.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return ne}var w=require("@shipstatic/types");A();A();ie();se();var $=require("@shipstatic/types");var S=F(require("fs"),1),x=F(require("path"),1);function Ie(e){let t=[];try{let o=S.readdirSync(e);for(let n of o){let i=x.join(e,n),s=S.statSync(i);if(s.isDirectory()){let r=Ie(i);t.push(...r)}else s.isFile()&&t.push(i)}}catch(o){console.error(`Error reading directory ${e}:`,o)}return t}async function Re(e,t={}){let o=x.resolve(e),i=(()=>{let c=S.statSync(o);return c.isFile()?[o]:c.isDirectory()?Ie(o):[]})().filter(c=>{let p=x.basename(c);return H([p]).length>0}),s;t.basePath?s=t.basePath:t.stripCommonPrefix?S.statSync(o).isDirectory()?s=o:s=x.dirname(o):S.statSync(o).isDirectory()?s=o:s=x.dirname(o);let r=[],l=0;for(let c of i)try{let p=S.statSync(c);if(p.size===0){console.warn(`Skipping empty file: ${c}`);continue}let m=T();if(p.size>m.maxFileSize)throw $.ShipError.business(`File ${c} is too large. Maximum allowed size is ${m.maxFileSize/(1024*1024)}MB.`);if(l+=p.size,l>m.maxTotalSize)throw $.ShipError.business(`Total deploy size is too large. Maximum allowed is ${m.maxTotalSize/(1024*1024)}MB.`);let y=S.readFileSync(c),{md5:d}=await j(y),U=x.relative(s,c).replace(/\\/g,"/");r.push({path:U,content:y,size:y.length,md5:d})}catch(p){if(p instanceof $.ShipError&&p.isClientError&&p.isClientError())throw p;console.error(`Could not process file ${c}:`,p)}let u=T();if(r.length>u.maxFilesCount)throw $.ShipError.business(`Too many files to deploy. Maximum allowed is ${u.maxFilesCount} files.`);return r}async function re(e,t={}){if(h()!=="node")throw $.ShipError.business("processFilesForNode can only be called in a Node.js environment.");if(e.length>1){let o=[];for(let n of e){let i=await Re(n,t);o.push(...i)}return o}return await Re(e[0],t)}q();function ke(e,t={}){let o=T();if(!t.skipEmptyCheck&&e.length===0)throw w.ShipError.business("No files to deploy.");if(e.length>o.maxFilesCount)throw w.ShipError.business(`Too many files to deploy. Maximum allowed is ${o.maxFilesCount}.`);let n=0;for(let i of e){if(i.size>o.maxFileSize)throw w.ShipError.business(`File ${i.name} is too large. Maximum allowed size is ${o.maxFileSize/(1024*1024)}MB.`);n+=i.size}if(n>o.maxTotalSize)throw w.ShipError.business(`Total deploy size is too large. Maximum allowed is ${o.maxTotalSize/(1024*1024)}MB.`)}function Le(e){return ke(e,{skipEmptyCheck:!0}),e.forEach(t=>{t.path&&(t.path=t.path.replace(/\\/g,"/"))}),e}async function ut(e,t={}){if(!Array.isArray(e)||!e.every(i=>typeof i=="string"))throw w.ShipError.business("Invalid input type for Node.js environment. Expected string[] file paths.");if(e.length===0)throw w.ShipError.business("No files to deploy.");let o={};if(t.stripCommonPrefix!==void 0&&(o.stripCommonPrefix=t.stripCommonPrefix,t.stripCommonPrefix)){let i=require("path"),s=typeof process<"u"?process.cwd():"/",r=e.map(c=>i.resolve(s,c)),{findCommonParent:l}=await Promise.resolve().then(()=>(ae(),$e)),u=l(r);u&&(o.basePath=u)}let n=await re(e,o);return Le(n)}async function yt(e,t={}){let o;if(e instanceof HTMLInputElement){if(!e.files)throw w.ShipError.business("No files selected in HTMLInputElement");o=Array.from(e.files)}else if(typeof e=="object"&&e!==null&&typeof e.length=="number"&&typeof e.item=="function")o=Array.from(e);else if(Array.isArray(e)){if(e.length>0&&typeof e[0]=="string")throw w.ShipError.business("Invalid input type for browser environment. Expected File[], FileList, or HTMLInputElement.");o=e}else throw w.ShipError.business("Invalid input type for browser environment. Expected File[], FileList, or HTMLInputElement.");o=o.filter(s=>s.size===0?(console.warn(`Skipping empty file: ${s.name}`),!1):!0),ke(o);let n={};if(t.stripCommonPrefix!==void 0&&(n.stripCommonPrefix=t.stripCommonPrefix,t.stripCommonPrefix)){let{findBrowserCommonParentDirectory:s}=await Promise.resolve().then(()=>(q(),Te)),r=s(e instanceof HTMLInputElement?e.files:e);r&&(n.basePath=r)}let i=await G(o,n);return Le(i)}async function Ue(e,t={}){let o=h();if(o==="node"){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"))throw w.ShipError.business("Invalid input type for Node.js environment. Expected string[] file paths.");return ut(e,t)}else if(o==="browser"){if(!(e instanceof HTMLInputElement||Array.isArray(e)||typeof FileList<"u"&&e instanceof FileList))throw w.ShipError.business("In browser, input must be FileList, File[], or HTMLInputElement.");return yt(e,t)}else throw w.ShipError.business("Unsupported execution environment.")}function Be(e,t,o){return{create:async(n,i={})=>{t&&await t();let s=o?xe(i,o):i,r=await Ue(n,s);return await e.deploy(r,s)},list:async()=>e.listDeployments(),remove:async n=>{await e.removeDeployment(n)},get:async n=>e.getDeployment(n)}}function Ne(e){return{set:async(t,o)=>e.setAlias(t,o),get:async t=>e.getAlias(t),list:async()=>e.listAliases(),remove:async t=>{await e.removeAlias(t)}}}function _e(e){return{get:async()=>e.getAccount()}}function ze(e){return{create:async()=>e.createApiKey()}}var Ke=require("@shipstatic/types");q();A();var J=class{constructor(t={}){this.configInitialized=!1;if(this.clientOptions=t,this.environment=h(),this.environment!=="node"&&this.environment!=="browser")throw Me.ShipError.business("Unsupported execution environment.");let o=we(),n=Pe(t,o);this.http=new K({...t,...n})}async initializeConfig(){if(this.configInitialized)return;let t=await this.http.getConfig();Ae(t),this.configInitialized=!0}async ping(){return this.http.ping()}get deployments(){return this._deployments||(this._deployments=Be(this.http,()=>this.initializeConfig(),this.clientOptions)),this._deployments}get aliases(){return this._aliases||(this._aliases=Ne(this.http)),this._aliases}get account(){return this._account||(this._account=_e(this.http)),this._account}get keys(){return this._keys||(this._keys=ze(this.http)),this._keys}async deploy(t,o){return this.deployments.create(t,o)}};var He=require("fs"),W=F(require("path"),1),Ge={version:"0.0.0"},dt=[W.resolve(__dirname,"../package.json"),W.resolve(__dirname,"../../package.json"),W.resolve(__dirname,"../../../package.json")];for(let e of dt)try{Ge=JSON.parse((0,He.readFileSync)(e,"utf-8"));break}catch{}var C=new je.Command;function b(e){console.error("Error:",e.message||e),process.exit(1)}function v(){let e=C.opts();return new J({apiUrl:e.api,apiKey:e.apiKey})}var ht={deployments:e=>{e.deployments.forEach(t=>{console.log(`${t.deployment} (${t.status})`)})},aliases:e=>{e.aliases.forEach(t=>{console.log(`${t.alias} -> ${t.deployment}`)})},deployment:e=>{console.log(`${e.deployment} (${e.status})`)},alias:e=>{console.log(`${e.alias} -> ${e.deployment}`)},email:e=>{console.log(`${e.email} (${e.subscription})`)}};function D(e){if(C.opts().json){console.log(JSON.stringify(e,null,2));return}for(let[o,n]of Object.entries(ht))if(e[o]){n(e);return}console.log("Success")}C.name("ship").description("CLI for Shipstatic").version(Ge.version).option("-u, --api <URL>","API URL").option("-k, --apiKey <KEY>","API key").option("--json","JSON output").addHelpText("after",`
|
|
2
|
+
"use strict";var Ge=Object.create;var Q=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var le=e=>{throw TypeError(e)};var $=(e,t)=>()=>(e&&(t=e(e=0)),t);var pe=(e,t)=>{for(var o in t)Q(e,o,{get:t[o],enumerable:!0})},Z=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Je(t))!Ve.call(e,i)&&i!==o&&Q(e,i,{get:()=>t[i],enumerable:!(n=qe(t,i))||n.enumerable});return e},me=(e,t,o)=>(Z(e,t,"default"),o&&Z(o,t,"default")),F=(e,t,o)=>(o=e!=null?Ge(We(e)):{},Z(t||!e||!e.__esModule?Q(o,"default",{value:e,enumerable:!0}):o,e));var Ye=(e,t,o)=>t.has(e)||le("Cannot "+o);var fe=(e,t,o)=>t.has(e)?le("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,o);var f=(e,t,o)=>(Ye(e,t,"access private method"),o);function Xe(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function h(){return ue||Xe()}var ue,A=$(()=>{"use strict";ue=null});async function st(e){let t=(await import("spark-md5")).default;return new Promise((o,n)=>{let s=Math.ceil(e.size/2097152),r=0,a=new t.ArrayBuffer,l=new FileReader,u=()=>{let p=r*2097152,m=Math.min(p+2097152,e.size);l.readAsArrayBuffer(e.slice(p,m))};l.onload=p=>{let m=p.target?.result;if(!m){n(R.ShipError.business("Failed to read file chunk"));return}a.append(m),r++,r<s?u():o({md5:a.end()})},l.onerror=()=>{n(R.ShipError.business("Failed to calculate MD5: FileReader error"))},u()})}async function rt(e){let t=await import("crypto");if(Buffer.isBuffer(e)){let n=t.createHash("md5");return n.update(e),{md5:n.digest("hex")}}let o=await import("fs");return new Promise((n,i)=>{let s=t.createHash("md5"),r=o.createReadStream(e);r.on("error",a=>i(R.ShipError.business(`Failed to read file for MD5: ${a.message}`))),r.on("data",a=>s.update(a)),r.on("end",()=>n({md5:s.digest("hex")}))})}async function j(e){let t=h();if(t==="browser"){if(!(e instanceof Blob))throw R.ShipError.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return st(e)}if(t==="node"){if(!(Buffer.isBuffer(e)||typeof e=="string"))throw R.ShipError.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return rt(e)}throw R.ShipError.business("Unknown or unsupported execution environment for MD5 calculation.")}var R,ne=$(()=>{"use strict";A();R=require("@shipstatic/types")});function H(e){return!e||e.length===0?[]:e.filter(t=>{if(!t)return!1;let o=t.replace(/\\/g,"/").split("/").filter(Boolean);if(o.length===0)return!0;let n=o[o.length-1];if((0,Ae.isJunk)(n))return!1;let i=o.slice(0,-1);for(let s of i)if(at.some(r=>s.toLowerCase()===r.toLowerCase()))return!1;return!0})}var Ae,at,ie=$(()=>{"use strict";Ae=require("junk"),at=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});var Ie={};pe(Ie,{ensureRelativePath:()=>pt,findCommonParent:()=>ct,findCommonParentDirectory:()=>k,normalizeSlashes:()=>lt,normalizeWebPath:()=>L});function k(e,t){if(!e||!Array.isArray(e)||e.length===0)return"";let o=e.filter(a=>a&&typeof a=="string");if(o.length===0)return"";let n=o.map(a=>{let l=a.replace(/\\/g,"/").replace(/^\/+/,"");return l.endsWith("/")?l:l+"/"});if(n.length===1)return n[0].slice(0,-1);let i=n.map(a=>a.split("/").filter(Boolean)),s=[],r=i[0];for(let a=0;a<r.length;a++){let l=r[a];if(i.every(p=>p.length>a&&p[a]===l))s.push(l);else break}return s.length===0?"":s.join("/")}function ct(e){if(typeof require>"u")return k(e,"/");let t=require("path");return k(e,t.sep)}function lt(e){return e.replace(/\\/g,"/")}function L(e){return e.replace(/\\/g,"/").replace(/^\/+/,"")}function pt(e){return L(e)}var re=$(()=>{"use strict"});var $e={};pe($e,{findBrowserCommonParentDirectory:()=>ce,processFilesForBrowser:()=>G});async function G(e,t={}){if(h()!=="browser")throw ae.ShipError.business("processFilesForBrowser can only be called in a browser environment.");let{explicitBaseDirInput:o,stripCommonPrefix:n}=t,i=[],s=Array.isArray(e)?e:Array.from(e),r="";n?r=ce(e):o&&(r=o);for(let m of s){let y=m.webkitRelativePath||m.name;if(r){y=L(y);let d=r.endsWith("/")?r:`${r}/`;(y===r||y===d||y.startsWith(d))&&(y=y.substring(d.length))}y=L(y),i.push({file:m,relativePath:y})}let a=i.map(m=>m.relativePath),l=H(a),u=new Set(l),p=[];for(let m of i){if(!u.has(m.relativePath)||m.file.size===0)continue;let{md5:y}=await j(m.file);p.push({content:m.file,path:m.relativePath,size:m.file.size,md5:y})}return p}function ce(e){if(h()!=="browser")throw ae.ShipError.business("findBrowserCommonParentDirectory can only be called in a browser environment.");if(!e||e.length===0)return"";let t=Array.from(e).map(o=>o.webkitRelativePath);return t.some(o=>!o)?"":k(t,"/")}var ae,q=$(()=>{"use strict";A();ne();ae=require("@shipstatic/types");re();ie()});var Me=require("commander");A();var O=require("zod"),de=require("cosmiconfig");var E={};me(E,require("@shipstatic/types"));A();var B="https://api.shipstatic.com";var ye="ship",Ze=O.z.object({apiUrl:O.z.string().url().optional(),apiKey:O.z.string().optional()}).strict();function he(e){try{return Ze.parse(e)}catch(t){if(t instanceof O.z.ZodError){let o=t.issues[0],n=o.path.length>0?` at ${o.path.join(".")}`:"";throw E.ShipError.config(`Configuration validation failed${n}: ${o.message}`)}throw E.ShipError.config("Configuration validation failed")}}function Qe(){try{let t=(0,de.cosmiconfigSync)(ye,{searchPlaces:[`.${ye}rc`,"package.json"]}).search();if(t&&!t.isEmpty&&t.config)return he(t.config)}catch(e){if(e instanceof E.ShipError)throw e}return{}}function ge(){if(h()!=="node")return{};let e={apiUrl:process.env.SHIP_API_URL,apiKey:process.env.SHIP_API_KEY},t=Qe(),o={apiUrl:e.apiUrl??t.apiUrl,apiKey:e.apiKey??t.apiKey};return he(o)}function we(e={},t={}){let o={apiUrl:e.apiUrl||t.apiUrl||B,apiKey:e.apiKey!==void 0?e.apiKey:t.apiKey};return o.apiKey!==void 0?{apiUrl:o.apiUrl,apiKey:o.apiKey}:{apiUrl:o.apiUrl}}function Pe(e={},t){let o={...e};return o.onProgress===void 0&&t.onProgress!==void 0&&(o.onProgress=t.onProgress),o.onProgressStats===void 0&&t.onProgressStats!==void 0&&(o.onProgressStats=t.onProgressStats),o.maxConcurrency===void 0&&t.maxConcurrentDeploys!==void 0&&(o.maxConcurrency=t.maxConcurrentDeploys),o.timeout===void 0&&t.timeout!==void 0&&(o.timeout=t.timeout),o.apiKey===void 0&&t.apiKey!==void 0&&(o.apiKey=t.apiKey),o.apiUrl===void 0&&t.apiUrl!==void 0&&(o.apiUrl=t.apiUrl),o}var M=F(require("mime-types"),1),g=require("@shipstatic/types");A();var N="/deployments",et="/ping",z="/aliases",tt="/config",ot="/account";function nt(e){return typeof e=="string"?M.lookup(e)||"application/octet-stream":M.lookup(e.name)||e.type||"application/octet-stream"}async function it(e){let t=[];for await(let o of e)t.push(o);return t}var c,be,ee,P,ve,xe,Fe,Se,te,_,K=class{constructor(t){fe(this,c);this.apiUrl=t.apiUrl||B,this.apiKey=t.apiKey??""}async ping(){return(await f(this,c,P).call(this,`${this.apiUrl}${et}`,{method:"GET"},"Ping"))?.success||!1}async getConfig(){return await f(this,c,P).call(this,`${this.apiUrl}${tt}`,{method:"GET"},"Config")}async deploy(t,o={}){f(this,c,ve).call(this,t);let{apiUrl:n=this.apiUrl,signal:i}=o;try{let{requestBody:s,requestHeaders:r}=await f(this,c,xe).call(this,t),a={method:"POST",body:s,headers:r,signal:i||null},l=await f(this,c,ee).call(this,`${n}${N}`,a,"Deploy");return l.ok||await f(this,c,te).call(this,l,"Deploy"),await l.json()}catch(s){throw s instanceof g.ShipError?s:(f(this,c,_).call(this,s,"Deploy"),g.ShipError.business("An unexpected error occurred and was not handled."))}}async listDeployments(){return await f(this,c,P).call(this,`${this.apiUrl}${N}`,{method:"GET"},"List Deployments")}async getDeployment(t){return await f(this,c,P).call(this,`${this.apiUrl}${N}/${t}`,{method:"GET"},"Get Deployment")}async removeDeployment(t){await f(this,c,P).call(this,`${this.apiUrl}${N}/${t}`,{method:"DELETE"},"Remove Deployment")}async setAlias(t,o){return await f(this,c,P).call(this,`${this.apiUrl}${z}/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({deploymentId:o})},"Set Alias")}async getAlias(t){return await f(this,c,P).call(this,`${this.apiUrl}${z}/${encodeURIComponent(t)}`,{method:"GET"},"Get Alias")}async listAliases(){return await f(this,c,P).call(this,`${this.apiUrl}${z}`,{method:"GET"},"List Aliases")}async removeAlias(t){await f(this,c,P).call(this,`${this.apiUrl}${z}/${encodeURIComponent(t)}`,{method:"DELETE"},"Remove Alias")}async getAccount(){return await f(this,c,P).call(this,`${this.apiUrl}${ot}`,{method:"GET"},"Get Account")}async createApiKey(){return await f(this,c,P).call(this,`${this.apiUrl}/key`,{method:"POST"},"Create API Key")}};c=new WeakSet,be=function(t={}){let o={...t};return this.apiKey&&(o.Authorization=`Bearer ${this.apiKey}`),o},ee=async function(t,o={},n){let i=f(this,c,be).call(this,o.headers),s={...o,headers:i,credentials:h()==="browser"?"include":"same-origin"};try{return await fetch(t,s)}catch(r){throw f(this,c,_).call(this,r,n),r}},P=async function(t,o={},n){try{let i=await f(this,c,ee).call(this,t,o,n);return i.ok||await f(this,c,te).call(this,i,n),i.headers.get("Content-Length")==="0"||i.status===204?void 0:await i.json()}catch(i){throw i instanceof g.ShipError||f(this,c,_).call(this,i,n),i}},ve=function(t){if(!t.length)throw g.ShipError.business("No files to deploy.");for(let o of t)if(!o.md5)throw g.ShipError.file(`MD5 checksum missing for file: ${o.path}`,o.path)},xe=async function(t){let o,n={};if(h()==="browser")o=f(this,c,Fe).call(this,t);else if(h()==="node"){let{body:i,headers:s}=await f(this,c,Se).call(this,t);o=i,n=s}else throw g.ShipError.business("Unknown or unsupported execution environment");return{requestBody:o,requestHeaders:n}},Fe=function(t){let o=new FormData,n=[];for(let i=0;i<t.length;i++){let s=t[i],r;if(s.content instanceof File||s.content instanceof Blob)r=s.content;else throw g.ShipError.file(`Unsupported file.content type for browser FormData: ${s.path}`,s.path);let a=nt(r instanceof File?r:s.path),l=new File([r],s.path,{type:a});o.append("files[]",l),n.push(s.md5)}return o.append("checksums",JSON.stringify(n)),o},Se=async function(t){let{FormData:o,File:n}=await import("formdata-node"),{FormDataEncoder:i}=await import("form-data-encoder"),s=await import("path"),r=new o,a=[];for(let y=0;y<t.length;y++){let d=t[y],U=M.lookup(d.path)||"application/octet-stream",X;if(Buffer.isBuffer(d.content))X=new n([d.content],s.basename(d.path),{type:U});else if(typeof Blob<"u"&&d.content instanceof Blob)X=new n([d.content],s.basename(d.path),{type:U});else throw g.ShipError.file(`Unsupported file.content type for Node.js FormData: ${d.path}`,d.path);let He=d.path.startsWith("/")?d.path:"/"+d.path;r.append("files[]",X,He),a.push(d.md5)}r.append("checksums",JSON.stringify(a));let l=new i(r),u=await it(l.encode()),p=Buffer.concat(u.map(y=>Buffer.from(y))),m={"Content-Type":l.contentType,"Content-Length":Buffer.byteLength(p).toString()};return{body:p,headers:m}},te=async function(t,o){let n={};try{let i=t.headers.get("content-type");i&&i.includes("application/json")?n=await t.json():n={message:await t.text()}}catch{n={message:"Failed to parse error response"}}if(n.error||n.code||n.message){let i=n.message||n.error||`${o} failed due to API error`;throw g.ShipError.api(i,t.status,n.code,n)}throw g.ShipError.api(`${o} failed due to API error`,t.status,void 0,n)},_=function(t,o){throw t.name==="AbortError"?g.ShipError.cancelled(`${o} operation was cancelled.`):t instanceof TypeError&&t.message.includes("fetch")?g.ShipError.network(`${o} failed due to network error: ${t.message}`,t):t instanceof g.ShipError?t:g.ShipError.business(`An unexpected error occurred during ${o}: ${t.message||"Unknown error"}`)};var ze=require("@shipstatic/types");var Ce=require("@shipstatic/types"),oe=null;function De(e){oe=e}function T(){if(oe===null)throw Ce.ShipError.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return oe}var w=require("@shipstatic/types");A();A();ne();ie();var I=require("@shipstatic/types");var S=F(require("fs"),1),b=F(require("path"),1);function Re(e){let t=[];try{let o=S.readdirSync(e);for(let n of o){let i=b.join(e,n),s=S.statSync(i);if(s.isDirectory()){let r=Re(i);t.push(...r)}else s.isFile()&&t.push(i)}}catch(o){console.error(`Error reading directory ${e}:`,o)}return t}async function Ee(e,t={}){let o=b.resolve(e),i=(()=>{let u=S.statSync(o);return u.isFile()?[o]:u.isDirectory()?Re(o):[]})().filter(u=>{let p=b.basename(u);return H([p]).length>0}),s;t.basePath?s=t.basePath:t.stripCommonPrefix?S.statSync(o).isDirectory()?s=o:s=b.dirname(o):S.statSync(o).isDirectory()?s=o:s=b.dirname(o);let r=[],a=0;for(let u of i)try{let p=S.statSync(u);if(p.size===0){console.warn(`Skipping empty file: ${u}`);continue}let m=T();if(p.size>m.maxFileSize)throw I.ShipError.business(`File ${u} is too large. Maximum allowed size is ${m.maxFileSize/(1024*1024)}MB.`);if(a+=p.size,a>m.maxTotalSize)throw I.ShipError.business(`Total deploy size is too large. Maximum allowed is ${m.maxTotalSize/(1024*1024)}MB.`);let y=S.readFileSync(u),{md5:d}=await j(y),U=b.relative(s,u).replace(/\\/g,"/");r.push({path:U,content:y,size:y.length,md5:d})}catch(p){if(p instanceof I.ShipError&&p.isClientError&&p.isClientError())throw p;console.error(`Could not process file ${u}:`,p)}let l=T();if(r.length>l.maxFilesCount)throw I.ShipError.business(`Too many files to deploy. Maximum allowed is ${l.maxFilesCount} files.`);return r}async function se(e,t={}){if(h()!=="node")throw I.ShipError.business("processFilesForNode can only be called in a Node.js environment.");if(e.length>1){let o=[];for(let n of e){let i=await Ee(n,t);o.push(...i)}return o}return await Ee(e[0],t)}q();function Oe(e,t={}){let o=T();if(!t.skipEmptyCheck&&e.length===0)throw w.ShipError.business("No files to deploy.");if(e.length>o.maxFilesCount)throw w.ShipError.business(`Too many files to deploy. Maximum allowed is ${o.maxFilesCount}.`);let n=0;for(let i of e){if(i.size>o.maxFileSize)throw w.ShipError.business(`File ${i.name} is too large. Maximum allowed size is ${o.maxFileSize/(1024*1024)}MB.`);n+=i.size}if(n>o.maxTotalSize)throw w.ShipError.business(`Total deploy size is too large. Maximum allowed is ${o.maxTotalSize/(1024*1024)}MB.`)}function Te(e){return Oe(e,{skipEmptyCheck:!0}),e.forEach(t=>{t.path&&(t.path=t.path.replace(/\\/g,"/"))}),e}async function mt(e,t={}){if(!Array.isArray(e)||!e.every(i=>typeof i=="string"))throw w.ShipError.business("Invalid input type for Node.js environment. Expected string[] file paths.");if(e.length===0)throw w.ShipError.business("No files to deploy.");let o={};if(t.stripCommonPrefix!==void 0&&(o.stripCommonPrefix=t.stripCommonPrefix,t.stripCommonPrefix)){let i=require("path"),s=typeof process<"u"?process.cwd():"/",r=e.map(u=>i.resolve(s,u)),{findCommonParent:a}=await Promise.resolve().then(()=>(re(),Ie)),l=a(r);l&&(o.basePath=l)}let n=await se(e,o);return Te(n)}async function ft(e,t={}){let o;if(e instanceof HTMLInputElement){if(!e.files)throw w.ShipError.business("No files selected in HTMLInputElement");o=Array.from(e.files)}else if(typeof e=="object"&&e!==null&&typeof e.length=="number"&&typeof e.item=="function")o=Array.from(e);else if(Array.isArray(e)){if(e.length>0&&typeof e[0]=="string")throw w.ShipError.business("Invalid input type for browser environment. Expected File[], FileList, or HTMLInputElement.");o=e}else throw w.ShipError.business("Invalid input type for browser environment. Expected File[], FileList, or HTMLInputElement.");o=o.filter(s=>s.size===0?(console.warn(`Skipping empty file: ${s.name}`),!1):!0),Oe(o);let n={};if(t.stripCommonPrefix!==void 0&&(n.stripCommonPrefix=t.stripCommonPrefix,t.stripCommonPrefix)){let{findBrowserCommonParentDirectory:s}=await Promise.resolve().then(()=>(q(),$e)),r=s(e instanceof HTMLInputElement?e.files:e);r&&(n.basePath=r)}let i=await G(o,n);return Te(i)}async function ke(e,t={}){let o=h();if(o==="node"){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"))throw w.ShipError.business("Invalid input type for Node.js environment. Expected string[] file paths.");return mt(e,t)}else if(o==="browser"){if(!(e instanceof HTMLInputElement||Array.isArray(e)||typeof FileList<"u"&&e instanceof FileList))throw w.ShipError.business("In browser, input must be FileList, File[], or HTMLInputElement.");return ft(e,t)}else throw w.ShipError.business("Unsupported execution environment.")}function Le(e,t,o){return{create:async(n,i={})=>{t&&await t();let s=o?Pe(i,o):i,r=await ke(n,s);return await e.deploy(r,s)},list:async()=>e.listDeployments(),remove:async n=>{await e.removeDeployment(n)},get:async n=>e.getDeployment(n)}}function Ue(e){return{set:async(t,o)=>e.setAlias(t,o),get:async t=>e.getAlias(t),list:async()=>e.listAliases(),remove:async t=>{await e.removeAlias(t)}}}function Be(e){return{get:async()=>e.getAccount()}}function Ne(e){return{create:async()=>e.createApiKey()}}var _e=require("@shipstatic/types");q();A();var J=class{constructor(t={}){this.configInitialized=!1;if(this.clientOptions=t,this.environment=h(),this.environment!=="node"&&this.environment!=="browser")throw ze.ShipError.business("Unsupported execution environment.");let o=ge(),n=we(t,o);this.http=new K({...t,...n})}async initializeConfig(){if(this.configInitialized)return;let t=await this.http.getConfig();De(t),this.configInitialized=!0}async ping(){return this.http.ping()}get deployments(){return this._deployments||(this._deployments=Le(this.http,()=>this.initializeConfig(),this.clientOptions)),this._deployments}get aliases(){return this._aliases||(this._aliases=Ue(this.http)),this._aliases}get account(){return this._account||(this._account=Be(this.http)),this._account}get keys(){return this._keys||(this._keys=Ne(this.http)),this._keys}async deploy(t,o){return this.deployments.create(t,o)}};var Ke=require("fs"),W=F(require("path"),1),je={version:"0.0.0"},ut=[W.resolve(__dirname,"../package.json"),W.resolve(__dirname,"../../package.json"),W.resolve(__dirname,"../../../package.json")];for(let e of ut)try{je=JSON.parse((0,Ke.readFileSync)(e,"utf-8"));break}catch{}var C=new Me.Command;function v(e){console.error("Error:",e.message||e),process.exit(1)}function x(){let e=C.opts();return new J({apiUrl:e.api,apiKey:e.apiKey})}var yt={deployments:e=>{e.deployments.forEach(t=>{console.log(`${t.deployment} (${t.status})`)})},aliases:e=>{e.aliases.forEach(t=>{console.log(`${t.alias} -> ${t.deployment}`)})},deployment:e=>{console.log(`${e.deployment} (${e.status})`)},alias:e=>{console.log(`${e.alias} -> ${e.deployment}`)},email:e=>{console.log(`${e.email} (${e.subscription})`)}};function D(e){if(C.opts().json){console.log(JSON.stringify(e,null,2));return}for(let[o,n]of Object.entries(yt))if(e[o]){n(e);return}console.log("Success")}C.name("ship").description("CLI for Shipstatic").version(je.version).option("-u, --api <URL>","API URL").option("-k, --apiKey <KEY>","API key").option("--json","JSON output").addHelpText("after",`
|
|
3
3
|
Examples:
|
|
4
4
|
ship ./path Deploy files (shortcut)
|
|
5
5
|
ship ping Check API connectivity
|
|
@@ -14,5 +14,5 @@ Examples:
|
|
|
14
14
|
ship aliases set staging abc123 Set alias to deployment
|
|
15
15
|
ship aliases remove staging Remove alias
|
|
16
16
|
|
|
17
|
-
ship account get Get account details`);C.command("ping").description("Check API connectivity").action(async()=>{try{let t=await
|
|
17
|
+
ship account get Get account details`);C.command("ping").description("Check API connectivity").action(async()=>{try{let t=await x().ping();console.log(t?"Connected":"Failed")}catch(e){v(e)}});var V=C.command("deployments").description("Manage deployments");V.command("list").description("List all deployments").action(async()=>{try{let t=await x().deployments.list();D(t)}catch(e){v(e)}});V.command("create <path>").description("Deploy files from path").action(async e=>{try{let o=await x().deployments.create([e]);D(o)}catch(t){v(t)}});V.command("get <id>").description("Get deployment details").action(async e=>{try{let o=await x().deployments.get(e);D(o)}catch(t){v(t)}});V.command("remove <id>").description("Remove deployment").action(async e=>{try{let o=await x().deployments.remove(e);D(o)}catch(t){v(t)}});var Y=C.command("aliases").description("Manage aliases");Y.command("list").description("List all aliases").action(async()=>{try{let t=await x().aliases.list();D(t)}catch(e){v(e)}});Y.command("get <name>").description("Get alias details").action(async e=>{try{let o=await x().aliases.get(e);D(o)}catch(t){v(t)}});Y.command("set <name> <deployment>").description("Set alias to deployment").action(async(e,t)=>{try{let n=await x().aliases.set(e,t);D(n)}catch(o){v(o)}});Y.command("remove <name>").description("Remove alias").action(async e=>{try{let o=await x().aliases.remove(e);D(o)}catch(t){v(t)}});var dt=C.command("account").description("Manage account");dt.command("get").description("Get account details").action(async()=>{try{let t=await x().account.get();D(t)}catch(e){v(e)}});C.argument("[path]","Path to deploy (shortcut)").action(async e=>{if(!e){C.help();return}if(e.startsWith("./")||e.startsWith("/")||e.startsWith("~")||e.includes("/"))try{let o=await x().deployments.create([e]);D(o)}catch(t){v(t)}else console.error("Unknown command:",e),console.error('Use "ship --help" for available commands'),process.exit(1)});process.env.NODE_ENV!=="test"&&C.parse(process.argv);
|
|
18
18
|
//# sourceMappingURL=cli.cjs.map
|