pinme 2.0.2-beta.4 → 2.0.2-beta.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/index.js +288 -295
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -96,9 +96,9 @@ var require_package = __commonJS({
|
|
|
96
96
|
// node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js
|
|
97
97
|
var require_main = __commonJS({
|
|
98
98
|
"node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"(exports2, module2) {
|
|
99
|
-
var
|
|
100
|
-
var
|
|
101
|
-
var
|
|
99
|
+
var fs16 = require("fs");
|
|
100
|
+
var path17 = require("path");
|
|
101
|
+
var os5 = require("os");
|
|
102
102
|
var crypto3 = require("crypto");
|
|
103
103
|
var packageJson = require_package();
|
|
104
104
|
var version2 = packageJson.version;
|
|
@@ -200,7 +200,7 @@ var require_main = __commonJS({
|
|
|
200
200
|
if (options && options.path && options.path.length > 0) {
|
|
201
201
|
if (Array.isArray(options.path)) {
|
|
202
202
|
for (const filepath of options.path) {
|
|
203
|
-
if (
|
|
203
|
+
if (fs16.existsSync(filepath)) {
|
|
204
204
|
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -208,15 +208,15 @@ var require_main = __commonJS({
|
|
|
208
208
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
209
209
|
}
|
|
210
210
|
} else {
|
|
211
|
-
possibleVaultPath =
|
|
211
|
+
possibleVaultPath = path17.resolve(process.cwd(), ".env.vault");
|
|
212
212
|
}
|
|
213
|
-
if (
|
|
213
|
+
if (fs16.existsSync(possibleVaultPath)) {
|
|
214
214
|
return possibleVaultPath;
|
|
215
215
|
}
|
|
216
216
|
return null;
|
|
217
217
|
}
|
|
218
218
|
function _resolveHome(envPath) {
|
|
219
|
-
return envPath[0] === "~" ?
|
|
219
|
+
return envPath[0] === "~" ? path17.join(os5.homedir(), envPath.slice(1)) : envPath;
|
|
220
220
|
}
|
|
221
221
|
function _configVault(options) {
|
|
222
222
|
const debug = Boolean(options && options.debug);
|
|
@@ -232,7 +232,7 @@ var require_main = __commonJS({
|
|
|
232
232
|
return { parsed };
|
|
233
233
|
}
|
|
234
234
|
function configDotenv(options) {
|
|
235
|
-
const dotenvPath =
|
|
235
|
+
const dotenvPath = path17.resolve(process.cwd(), ".env");
|
|
236
236
|
let encoding = "utf8";
|
|
237
237
|
const debug = Boolean(options && options.debug);
|
|
238
238
|
if (options && options.encoding) {
|
|
@@ -255,13 +255,13 @@ var require_main = __commonJS({
|
|
|
255
255
|
}
|
|
256
256
|
let lastError;
|
|
257
257
|
const parsedAll = {};
|
|
258
|
-
for (const
|
|
258
|
+
for (const path18 of optionPaths) {
|
|
259
259
|
try {
|
|
260
|
-
const parsed = DotenvModule.parse(
|
|
260
|
+
const parsed = DotenvModule.parse(fs16.readFileSync(path18, { encoding }));
|
|
261
261
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
262
262
|
} catch (e) {
|
|
263
263
|
if (debug) {
|
|
264
|
-
_debug(`Failed to load ${
|
|
264
|
+
_debug(`Failed to load ${path18} ${e.message}`);
|
|
265
265
|
}
|
|
266
266
|
lastError = e;
|
|
267
267
|
}
|
|
@@ -810,7 +810,7 @@ var require_has_flag = __commonJS({
|
|
|
810
810
|
var require_supports_color = __commonJS({
|
|
811
811
|
"node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js"(exports2, module2) {
|
|
812
812
|
"use strict";
|
|
813
|
-
var
|
|
813
|
+
var os5 = require("os");
|
|
814
814
|
var hasFlag = require_has_flag();
|
|
815
815
|
var env = process.env;
|
|
816
816
|
var forceColor;
|
|
@@ -848,7 +848,7 @@ var require_supports_color = __commonJS({
|
|
|
848
848
|
}
|
|
849
849
|
const min = forceColor ? 1 : 0;
|
|
850
850
|
if (process.platform === "win32") {
|
|
851
|
-
const osRelease =
|
|
851
|
+
const osRelease = os5.release().split(".");
|
|
852
852
|
if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
853
853
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
854
854
|
}
|
|
@@ -1523,10 +1523,10 @@ var import_chalk25 = __toESM(require("chalk"));
|
|
|
1523
1523
|
var import_figlet5 = __toESM(require("figlet"));
|
|
1524
1524
|
|
|
1525
1525
|
// package.json
|
|
1526
|
-
var version = "2.0.2-beta.
|
|
1526
|
+
var version = "2.0.2-beta.5";
|
|
1527
1527
|
|
|
1528
1528
|
// bin/upload.ts
|
|
1529
|
-
var
|
|
1529
|
+
var import_path6 = __toESM(require("path"));
|
|
1530
1530
|
var import_chalk5 = __toESM(require("chalk"));
|
|
1531
1531
|
var import_inquirer = __toESM(require("inquirer"));
|
|
1532
1532
|
var import_figlet = __toESM(require("figlet"));
|
|
@@ -1972,9 +1972,9 @@ function isVisitable(thing) {
|
|
|
1972
1972
|
function removeBrackets(key) {
|
|
1973
1973
|
return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
|
|
1974
1974
|
}
|
|
1975
|
-
function renderKey(
|
|
1976
|
-
if (!
|
|
1977
|
-
return
|
|
1975
|
+
function renderKey(path17, key, dots) {
|
|
1976
|
+
if (!path17) return key;
|
|
1977
|
+
return path17.concat(key).map(function each(token, i) {
|
|
1978
1978
|
token = removeBrackets(token);
|
|
1979
1979
|
return !dots && i ? "[" + token + "]" : token;
|
|
1980
1980
|
}).join(dots ? "." : "");
|
|
@@ -2019,9 +2019,9 @@ function toFormData(obj, formData, options) {
|
|
|
2019
2019
|
}
|
|
2020
2020
|
return value;
|
|
2021
2021
|
}
|
|
2022
|
-
function defaultVisitor(value, key,
|
|
2022
|
+
function defaultVisitor(value, key, path17) {
|
|
2023
2023
|
let arr = value;
|
|
2024
|
-
if (value && !
|
|
2024
|
+
if (value && !path17 && typeof value === "object") {
|
|
2025
2025
|
if (utils_default.endsWith(key, "{}")) {
|
|
2026
2026
|
key = metaTokens ? key : key.slice(0, -2);
|
|
2027
2027
|
value = JSON.stringify(value);
|
|
@@ -2040,7 +2040,7 @@ function toFormData(obj, formData, options) {
|
|
|
2040
2040
|
if (isVisitable(value)) {
|
|
2041
2041
|
return true;
|
|
2042
2042
|
}
|
|
2043
|
-
formData.append(renderKey(
|
|
2043
|
+
formData.append(renderKey(path17, key, dots), convertValue(value));
|
|
2044
2044
|
return false;
|
|
2045
2045
|
}
|
|
2046
2046
|
const stack = [];
|
|
@@ -2049,10 +2049,10 @@ function toFormData(obj, formData, options) {
|
|
|
2049
2049
|
convertValue,
|
|
2050
2050
|
isVisitable
|
|
2051
2051
|
});
|
|
2052
|
-
function build(value,
|
|
2052
|
+
function build(value, path17) {
|
|
2053
2053
|
if (utils_default.isUndefined(value)) return;
|
|
2054
2054
|
if (stack.indexOf(value) !== -1) {
|
|
2055
|
-
throw Error("Circular reference detected in " +
|
|
2055
|
+
throw Error("Circular reference detected in " + path17.join("."));
|
|
2056
2056
|
}
|
|
2057
2057
|
stack.push(value);
|
|
2058
2058
|
utils_default.forEach(value, function each(el, key) {
|
|
@@ -2060,11 +2060,11 @@ function toFormData(obj, formData, options) {
|
|
|
2060
2060
|
formData,
|
|
2061
2061
|
el,
|
|
2062
2062
|
utils_default.isString(key) ? key.trim() : key,
|
|
2063
|
-
|
|
2063
|
+
path17,
|
|
2064
2064
|
exposedHelpers
|
|
2065
2065
|
);
|
|
2066
2066
|
if (result === true) {
|
|
2067
|
-
build(el,
|
|
2067
|
+
build(el, path17 ? path17.concat(key) : [key]);
|
|
2068
2068
|
}
|
|
2069
2069
|
});
|
|
2070
2070
|
stack.pop();
|
|
@@ -2225,7 +2225,7 @@ var node_default = {
|
|
|
2225
2225
|
// node_modules/.pnpm/axios@1.3.2/node_modules/axios/lib/helpers/toURLEncodedForm.js
|
|
2226
2226
|
function toURLEncodedForm(data, options) {
|
|
2227
2227
|
return toFormData_default(data, new node_default.classes.URLSearchParams(), Object.assign({
|
|
2228
|
-
visitor: function(value, key,
|
|
2228
|
+
visitor: function(value, key, path17, helpers) {
|
|
2229
2229
|
if (node_default.isNode && utils_default.isBuffer(value)) {
|
|
2230
2230
|
this.append(key, value.toString("base64"));
|
|
2231
2231
|
return false;
|
|
@@ -2254,10 +2254,10 @@ function arrayToObject(arr) {
|
|
|
2254
2254
|
return obj;
|
|
2255
2255
|
}
|
|
2256
2256
|
function formDataToJSON(formData) {
|
|
2257
|
-
function buildPath(
|
|
2258
|
-
let name =
|
|
2257
|
+
function buildPath(path17, value, target, index) {
|
|
2258
|
+
let name = path17[index++];
|
|
2259
2259
|
const isNumericKey = Number.isFinite(+name);
|
|
2260
|
-
const isLast = index >=
|
|
2260
|
+
const isLast = index >= path17.length;
|
|
2261
2261
|
name = !name && utils_default.isArray(target) ? target.length : name;
|
|
2262
2262
|
if (isLast) {
|
|
2263
2263
|
if (utils_default.hasOwnProp(target, name)) {
|
|
@@ -2270,7 +2270,7 @@ function formDataToJSON(formData) {
|
|
|
2270
2270
|
if (!target[name] || !utils_default.isObject(target[name])) {
|
|
2271
2271
|
target[name] = [];
|
|
2272
2272
|
}
|
|
2273
|
-
const result = buildPath(
|
|
2273
|
+
const result = buildPath(path17, value, target[name], index);
|
|
2274
2274
|
if (result && utils_default.isArray(target[name])) {
|
|
2275
2275
|
target[name] = arrayToObject(target[name]);
|
|
2276
2276
|
}
|
|
@@ -3332,9 +3332,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3332
3332
|
auth = urlUsername + ":" + urlPassword;
|
|
3333
3333
|
}
|
|
3334
3334
|
auth && headers.delete("authorization");
|
|
3335
|
-
let
|
|
3335
|
+
let path17;
|
|
3336
3336
|
try {
|
|
3337
|
-
|
|
3337
|
+
path17 = buildURL(
|
|
3338
3338
|
parsed.pathname + parsed.search,
|
|
3339
3339
|
config.params,
|
|
3340
3340
|
config.paramsSerializer
|
|
@@ -3352,7 +3352,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3352
3352
|
false
|
|
3353
3353
|
);
|
|
3354
3354
|
const options = {
|
|
3355
|
-
path:
|
|
3355
|
+
path: path17,
|
|
3356
3356
|
method,
|
|
3357
3357
|
headers: headers.toJSON(),
|
|
3358
3358
|
agents: { http: config.httpAgent, https: config.httpsAgent },
|
|
@@ -3571,14 +3571,14 @@ var cookies_default = node_default.isStandardBrowserEnv ? (
|
|
|
3571
3571
|
// Standard browser envs support document.cookie
|
|
3572
3572
|
/* @__PURE__ */ function standardBrowserEnv() {
|
|
3573
3573
|
return {
|
|
3574
|
-
write: function write(name, value, expires,
|
|
3574
|
+
write: function write(name, value, expires, path17, domain, secure) {
|
|
3575
3575
|
const cookie = [];
|
|
3576
3576
|
cookie.push(name + "=" + encodeURIComponent(value));
|
|
3577
3577
|
if (utils_default.isNumber(expires)) {
|
|
3578
3578
|
cookie.push("expires=" + new Date(expires).toGMTString());
|
|
3579
3579
|
}
|
|
3580
|
-
if (utils_default.isString(
|
|
3581
|
-
cookie.push("path=" +
|
|
3580
|
+
if (utils_default.isString(path17)) {
|
|
3581
|
+
cookie.push("path=" + path17);
|
|
3582
3582
|
}
|
|
3583
3583
|
if (utils_default.isString(domain)) {
|
|
3584
3584
|
cookie.push("domain=" + domain);
|
|
@@ -5263,44 +5263,25 @@ function validateDnsDomain(domain) {
|
|
|
5263
5263
|
var import_crypto_js = __toESM(require("crypto-js"));
|
|
5264
5264
|
|
|
5265
5265
|
// bin/utils/getDeviceId.ts
|
|
5266
|
-
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
5267
|
-
var import_path3 = __toESM(require("path"));
|
|
5268
|
-
var import_os3 = __toESM(require("os"));
|
|
5269
|
-
var import_uuid = require("uuid");
|
|
5270
|
-
|
|
5271
|
-
// bin/utils/auth.ts
|
|
5272
5266
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
5273
|
-
var import_os2 = __toESM(require("os"));
|
|
5274
5267
|
var import_path2 = __toESM(require("path"));
|
|
5275
|
-
var
|
|
5276
|
-
var
|
|
5277
|
-
function getAuthConfig2() {
|
|
5278
|
-
try {
|
|
5279
|
-
if (!import_fs_extra2.default.existsSync(AUTH_FILE2)) return null;
|
|
5280
|
-
const data = import_fs_extra2.default.readJsonSync(AUTH_FILE2);
|
|
5281
|
-
if (!(data == null ? void 0 : data.address) || !(data == null ? void 0 : data.token)) return null;
|
|
5282
|
-
return data;
|
|
5283
|
-
} catch {
|
|
5284
|
-
return null;
|
|
5285
|
-
}
|
|
5286
|
-
}
|
|
5287
|
-
|
|
5288
|
-
// bin/utils/getDeviceId.ts
|
|
5268
|
+
var import_os2 = __toESM(require("os"));
|
|
5269
|
+
var import_uuid = require("uuid");
|
|
5289
5270
|
function getDeviceId() {
|
|
5290
|
-
const configDir =
|
|
5291
|
-
const configFile =
|
|
5292
|
-
if (!
|
|
5293
|
-
|
|
5271
|
+
const configDir = import_path2.default.join(import_os2.default.homedir(), ".pinme");
|
|
5272
|
+
const configFile = import_path2.default.join(configDir, "device-id");
|
|
5273
|
+
if (!import_fs_extra2.default.existsSync(configDir)) {
|
|
5274
|
+
import_fs_extra2.default.mkdirSync(configDir, { recursive: true });
|
|
5294
5275
|
}
|
|
5295
|
-
if (
|
|
5296
|
-
return
|
|
5276
|
+
if (import_fs_extra2.default.existsSync(configFile)) {
|
|
5277
|
+
return import_fs_extra2.default.readFileSync(configFile, "utf8").trim();
|
|
5297
5278
|
}
|
|
5298
5279
|
const deviceId = (0, import_uuid.v4)();
|
|
5299
|
-
|
|
5280
|
+
import_fs_extra2.default.writeFileSync(configFile, deviceId);
|
|
5300
5281
|
return deviceId;
|
|
5301
5282
|
}
|
|
5302
5283
|
function getUid() {
|
|
5303
|
-
const auth =
|
|
5284
|
+
const auth = getAuthConfig();
|
|
5304
5285
|
if (auth == null ? void 0 : auth.address) {
|
|
5305
5286
|
return auth.address;
|
|
5306
5287
|
}
|
|
@@ -5308,15 +5289,15 @@ function getUid() {
|
|
|
5308
5289
|
}
|
|
5309
5290
|
|
|
5310
5291
|
// bin/utils/uploadToIpfsSplit.ts
|
|
5311
|
-
var
|
|
5312
|
-
var
|
|
5292
|
+
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
5293
|
+
var import_path5 = __toESM(require("path"));
|
|
5313
5294
|
var import_form_data2 = __toESM(require("form-data"));
|
|
5314
5295
|
var import_ora = __toESM(require("ora"));
|
|
5315
5296
|
var crypto2 = __toESM(require("crypto"));
|
|
5316
5297
|
|
|
5317
5298
|
// bin/utils/uploadLimits.ts
|
|
5318
5299
|
var import_fs = __toESM(require("fs"));
|
|
5319
|
-
var
|
|
5300
|
+
var import_path3 = __toESM(require("path"));
|
|
5320
5301
|
var FILE_SIZE_LIMIT = parseInt("500", 10) * 1024 * 1024;
|
|
5321
5302
|
var DIRECTORY_SIZE_LIMIT = parseInt("500", 10) * 1024 * 1024;
|
|
5322
5303
|
function checkFileSizeLimit(filePath) {
|
|
@@ -5339,7 +5320,7 @@ function calculateDirectorySize(directoryPath) {
|
|
|
5339
5320
|
let totalSize = 0;
|
|
5340
5321
|
const files = import_fs.default.readdirSync(directoryPath);
|
|
5341
5322
|
for (const file of files) {
|
|
5342
|
-
const filePath =
|
|
5323
|
+
const filePath = import_path3.default.join(directoryPath, file);
|
|
5343
5324
|
const stats = import_fs.default.statSync(filePath);
|
|
5344
5325
|
if (stats.isFile()) {
|
|
5345
5326
|
totalSize += stats.size;
|
|
@@ -5357,30 +5338,30 @@ function formatSize(bytes) {
|
|
|
5357
5338
|
}
|
|
5358
5339
|
|
|
5359
5340
|
// bin/utils/history.ts
|
|
5360
|
-
var
|
|
5361
|
-
var
|
|
5362
|
-
var
|
|
5341
|
+
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
5342
|
+
var import_path4 = __toESM(require("path"));
|
|
5343
|
+
var import_os3 = __toESM(require("os"));
|
|
5363
5344
|
var import_dayjs = __toESM(require("dayjs"));
|
|
5364
5345
|
var import_chalk4 = __toESM(require("chalk"));
|
|
5365
|
-
var HISTORY_DIR =
|
|
5366
|
-
var HISTORY_FILE =
|
|
5346
|
+
var HISTORY_DIR = import_path4.default.join(import_os3.default.homedir(), ".pinme");
|
|
5347
|
+
var HISTORY_FILE = import_path4.default.join(HISTORY_DIR, "upload-history.json");
|
|
5367
5348
|
var ensureHistoryDir = () => {
|
|
5368
|
-
if (!
|
|
5369
|
-
|
|
5349
|
+
if (!import_fs_extra3.default.existsSync(HISTORY_DIR)) {
|
|
5350
|
+
import_fs_extra3.default.mkdirSync(HISTORY_DIR, { recursive: true });
|
|
5370
5351
|
}
|
|
5371
|
-
if (!
|
|
5372
|
-
|
|
5352
|
+
if (!import_fs_extra3.default.existsSync(HISTORY_FILE)) {
|
|
5353
|
+
import_fs_extra3.default.writeJsonSync(HISTORY_FILE, { uploads: [] });
|
|
5373
5354
|
}
|
|
5374
5355
|
};
|
|
5375
5356
|
var saveUploadHistory = (uploadData) => {
|
|
5376
5357
|
try {
|
|
5377
5358
|
ensureHistoryDir();
|
|
5378
|
-
const history =
|
|
5359
|
+
const history = import_fs_extra3.default.readJsonSync(HISTORY_FILE);
|
|
5379
5360
|
const newRecord = {
|
|
5380
5361
|
timestamp: Date.now(),
|
|
5381
5362
|
date: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"),
|
|
5382
5363
|
path: uploadData.path,
|
|
5383
|
-
filename: uploadData.filename ||
|
|
5364
|
+
filename: uploadData.filename || import_path4.default.basename(uploadData.path),
|
|
5384
5365
|
contentHash: uploadData.contentHash,
|
|
5385
5366
|
previewHash: uploadData.previewHash,
|
|
5386
5367
|
size: uploadData.size,
|
|
@@ -5389,7 +5370,7 @@ var saveUploadHistory = (uploadData) => {
|
|
|
5389
5370
|
shortUrl: (uploadData == null ? void 0 : uploadData.shortUrl) || null
|
|
5390
5371
|
};
|
|
5391
5372
|
history.uploads.unshift(newRecord);
|
|
5392
|
-
|
|
5373
|
+
import_fs_extra3.default.writeJsonSync(HISTORY_FILE, history, { spaces: 2 });
|
|
5393
5374
|
return true;
|
|
5394
5375
|
} catch (error) {
|
|
5395
5376
|
console.error(import_chalk4.default.red(`Error saving upload history: ${error.message}`));
|
|
@@ -5399,7 +5380,7 @@ var saveUploadHistory = (uploadData) => {
|
|
|
5399
5380
|
var getUploadHistory = (limit = 10) => {
|
|
5400
5381
|
try {
|
|
5401
5382
|
ensureHistoryDir();
|
|
5402
|
-
const history =
|
|
5383
|
+
const history = import_fs_extra3.default.readJsonSync(HISTORY_FILE);
|
|
5403
5384
|
return history.uploads.slice(0, limit);
|
|
5404
5385
|
} catch (error) {
|
|
5405
5386
|
console.error(import_chalk4.default.red(`Error reading upload history: ${error.message}`));
|
|
@@ -5439,7 +5420,7 @@ var displayUploadHistory = (limit = 10) => {
|
|
|
5439
5420
|
var clearUploadHistory = () => {
|
|
5440
5421
|
try {
|
|
5441
5422
|
ensureHistoryDir();
|
|
5442
|
-
|
|
5423
|
+
import_fs_extra3.default.writeJsonSync(HISTORY_FILE, { uploads: [] });
|
|
5443
5424
|
console.log(import_chalk4.default.green("Upload history cleared successfully."));
|
|
5444
5425
|
return true;
|
|
5445
5426
|
} catch (error) {
|
|
@@ -5560,7 +5541,7 @@ var StepProgressBar = class {
|
|
|
5560
5541
|
async function calculateMD5(filePath) {
|
|
5561
5542
|
return new Promise((resolve, reject) => {
|
|
5562
5543
|
const hash = crypto2.createHash("md5");
|
|
5563
|
-
const stream4 =
|
|
5544
|
+
const stream4 = import_fs_extra4.default.createReadStream(filePath);
|
|
5564
5545
|
stream4.on("data", hash.update.bind(hash));
|
|
5565
5546
|
stream4.on("end", () => resolve(hash.digest("hex")));
|
|
5566
5547
|
stream4.on("error", reject);
|
|
@@ -5569,20 +5550,20 @@ async function calculateMD5(filePath) {
|
|
|
5569
5550
|
async function compressDirectory(sourcePath) {
|
|
5570
5551
|
return new Promise((resolve, reject) => {
|
|
5571
5552
|
const tempDir = require("os").tmpdir();
|
|
5572
|
-
if (!
|
|
5573
|
-
|
|
5553
|
+
if (!import_fs_extra4.default.existsSync(tempDir)) {
|
|
5554
|
+
import_fs_extra4.default.mkdirSync(tempDir, { recursive: true });
|
|
5574
5555
|
}
|
|
5575
|
-
const outputPath =
|
|
5556
|
+
const outputPath = import_path5.default.join(
|
|
5576
5557
|
tempDir,
|
|
5577
|
-
`pinme_${
|
|
5558
|
+
`pinme_${import_path5.default.basename(sourcePath)}_${Date.now()}.zip`
|
|
5578
5559
|
);
|
|
5579
|
-
const output =
|
|
5560
|
+
const output = import_fs_extra4.default.createWriteStream(outputPath);
|
|
5580
5561
|
const zlib2 = require("zlib");
|
|
5581
5562
|
const gzip = zlib2.createGzip({ level: 9 });
|
|
5582
5563
|
output.on("close", () => resolve(outputPath));
|
|
5583
5564
|
gzip.on("error", reject);
|
|
5584
5565
|
gzip.pipe(output);
|
|
5585
|
-
const stats =
|
|
5566
|
+
const stats = import_fs_extra4.default.statSync(sourcePath);
|
|
5586
5567
|
if (stats.isDirectory()) {
|
|
5587
5568
|
const archive = require("archiver");
|
|
5588
5569
|
const archiveStream = archive("zip", { zlib: { level: 9 } });
|
|
@@ -5591,14 +5572,14 @@ async function compressDirectory(sourcePath) {
|
|
|
5591
5572
|
archiveStream.directory(sourcePath, false);
|
|
5592
5573
|
archiveStream.finalize();
|
|
5593
5574
|
} else {
|
|
5594
|
-
const fileStream =
|
|
5575
|
+
const fileStream = import_fs_extra4.default.createReadStream(sourcePath);
|
|
5595
5576
|
fileStream.pipe(gzip);
|
|
5596
5577
|
}
|
|
5597
5578
|
});
|
|
5598
5579
|
}
|
|
5599
5580
|
async function initChunkSession(filePath, deviceId, isDirectory = false) {
|
|
5600
|
-
const stats =
|
|
5601
|
-
const fileName =
|
|
5581
|
+
const stats = import_fs_extra4.default.statSync(filePath);
|
|
5582
|
+
const fileName = import_path5.default.basename(filePath);
|
|
5602
5583
|
const fileSize = stats.size;
|
|
5603
5584
|
const md5 = await calculateMD5(filePath);
|
|
5604
5585
|
try {
|
|
@@ -5699,7 +5680,7 @@ async function delayWithAbortCheck(delay, signal) {
|
|
|
5699
5680
|
});
|
|
5700
5681
|
}
|
|
5701
5682
|
async function uploadFileChunks(filePath, sessionId, totalChunks, chunkSize, deviceId, progressBar) {
|
|
5702
|
-
const fileData =
|
|
5683
|
+
const fileData = import_fs_extra4.default.readFileSync(filePath);
|
|
5703
5684
|
const abortController = new AbortController();
|
|
5704
5685
|
let completedCount = 0;
|
|
5705
5686
|
let hasFatalError = false;
|
|
@@ -5864,7 +5845,7 @@ async function uploadDirectoryInChunks(directoryPath, deviceId, options = {}) {
|
|
|
5864
5845
|
)} (size: ${formatSize(sizeCheck.size)})`
|
|
5865
5846
|
);
|
|
5866
5847
|
}
|
|
5867
|
-
const progressBar = new StepProgressBar(
|
|
5848
|
+
const progressBar = new StepProgressBar(import_path5.default.basename(directoryPath), true);
|
|
5868
5849
|
try {
|
|
5869
5850
|
progressBar.startStep(0, "Preparing compression");
|
|
5870
5851
|
const compressedPath = await compressDirectory(directoryPath);
|
|
@@ -5893,12 +5874,12 @@ async function uploadDirectoryInChunks(directoryPath, deviceId, options = {}) {
|
|
|
5893
5874
|
const result = await monitorChunkProgress(traceId, deviceId, options, progressBar);
|
|
5894
5875
|
progressBar.completeStep();
|
|
5895
5876
|
try {
|
|
5896
|
-
|
|
5877
|
+
import_fs_extra4.default.unlinkSync(compressedPath);
|
|
5897
5878
|
} catch (error) {
|
|
5898
5879
|
}
|
|
5899
5880
|
const uploadData = {
|
|
5900
5881
|
path: directoryPath,
|
|
5901
|
-
filename:
|
|
5882
|
+
filename: import_path5.default.basename(directoryPath),
|
|
5902
5883
|
contentHash: (result == null ? void 0 : result.hash) || "unknown",
|
|
5903
5884
|
size: sizeCheck.size,
|
|
5904
5885
|
fileCount: 0,
|
|
@@ -5925,7 +5906,7 @@ async function uploadFileInChunks(filePath, deviceId, options = {}) {
|
|
|
5925
5906
|
)} (size: ${formatSize(sizeCheck.size)})`
|
|
5926
5907
|
);
|
|
5927
5908
|
}
|
|
5928
|
-
const fileName =
|
|
5909
|
+
const fileName = import_path5.default.basename(filePath);
|
|
5929
5910
|
const progressBar = new StepProgressBar(fileName, false);
|
|
5930
5911
|
try {
|
|
5931
5912
|
progressBar.startStep(0, "Initializing session");
|
|
@@ -5973,13 +5954,14 @@ async function uploadFileInChunks(filePath, deviceId, options = {}) {
|
|
|
5973
5954
|
}
|
|
5974
5955
|
}
|
|
5975
5956
|
async function uploadToIpfsSplit_default(filePath, options = {}) {
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5957
|
+
var _a2;
|
|
5958
|
+
const uid = ((_a2 = options.uid) == null ? void 0 : _a2.trim()) || getUid();
|
|
5959
|
+
if (!uid) {
|
|
5960
|
+
throw new Error("Upload uid not found");
|
|
5979
5961
|
}
|
|
5980
5962
|
try {
|
|
5981
|
-
const isDirectory =
|
|
5982
|
-
const result = isDirectory ? await uploadDirectoryInChunks(filePath,
|
|
5963
|
+
const isDirectory = import_fs_extra4.default.statSync(filePath).isDirectory();
|
|
5964
|
+
const result = isDirectory ? await uploadDirectoryInChunks(filePath, uid, options) : await uploadFileInChunks(filePath, uid, options);
|
|
5983
5965
|
if (result == null ? void 0 : result.hash) {
|
|
5984
5966
|
return {
|
|
5985
5967
|
contentHash: result.hash,
|
|
@@ -6018,9 +6000,9 @@ function formatShortUrl(shortUrl) {
|
|
|
6018
6000
|
}
|
|
6019
6001
|
return `https://${normalized}.pinit.eth.limo`;
|
|
6020
6002
|
}
|
|
6021
|
-
function resolveUploadUrls(contentHash, shortUrl) {
|
|
6022
|
-
const
|
|
6023
|
-
const encryptedCID = encryptHash(contentHash, APP_CONFIG.secretKey,
|
|
6003
|
+
function resolveUploadUrls(contentHash, shortUrl, uid) {
|
|
6004
|
+
const resolvedUid = (uid == null ? void 0 : uid.trim()) || getUid();
|
|
6005
|
+
const encryptedCID = encryptHash(contentHash, APP_CONFIG.secretKey, resolvedUid);
|
|
6024
6006
|
const managementUrl = `${APP_CONFIG.ipfsPreviewUrl}${encryptedCID}`;
|
|
6025
6007
|
const publicUrl = formatShortUrl(shortUrl) || managementUrl;
|
|
6026
6008
|
return {
|
|
@@ -6031,12 +6013,13 @@ function resolveUploadUrls(contentHash, shortUrl) {
|
|
|
6031
6013
|
async function uploadPath(targetPath, options = {}) {
|
|
6032
6014
|
const result = await uploadToIpfsSplit_default(targetPath, {
|
|
6033
6015
|
importAsCar: options.importAsCar,
|
|
6034
|
-
projectName: options.projectName
|
|
6016
|
+
projectName: options.projectName,
|
|
6017
|
+
uid: options.uid
|
|
6035
6018
|
});
|
|
6036
6019
|
if (!(result == null ? void 0 : result.contentHash)) {
|
|
6037
6020
|
throw new Error("Upload failed: no content hash returned");
|
|
6038
6021
|
}
|
|
6039
|
-
const urls = resolveUploadUrls(result.contentHash, result.shortUrl);
|
|
6022
|
+
const urls = resolveUploadUrls(result.contentHash, result.shortUrl, options.uid);
|
|
6040
6023
|
return {
|
|
6041
6024
|
contentHash: result.contentHash,
|
|
6042
6025
|
shortUrl: result.shortUrl,
|
|
@@ -6049,7 +6032,7 @@ async function uploadPath(targetPath, options = {}) {
|
|
|
6049
6032
|
checkNodeVersion();
|
|
6050
6033
|
function checkPathSync(inputPath) {
|
|
6051
6034
|
try {
|
|
6052
|
-
const absolutePath =
|
|
6035
|
+
const absolutePath = import_path6.default.resolve(inputPath);
|
|
6053
6036
|
if (import_fs2.default.existsSync(absolutePath)) {
|
|
6054
6037
|
return absolutePath;
|
|
6055
6038
|
}
|
|
@@ -6141,13 +6124,10 @@ var upload_default = async (options) => {
|
|
|
6141
6124
|
const domainArg = getDomainFromArgs();
|
|
6142
6125
|
const dnsArg = getDnsFromArgs();
|
|
6143
6126
|
const needsAuth = !!domainArg || dnsArg;
|
|
6144
|
-
|
|
6145
|
-
if (needsAuth) {
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
console.log(import_chalk5.default.red("Please login first. Run: pinme set-appkey <AppKey>"));
|
|
6149
|
-
return;
|
|
6150
|
-
}
|
|
6127
|
+
const authConfig = getAuthConfig();
|
|
6128
|
+
if (needsAuth && !authConfig) {
|
|
6129
|
+
console.log(import_chalk5.default.red("Please login first. Run: pinme set-appkey <AppKey>"));
|
|
6130
|
+
return;
|
|
6151
6131
|
}
|
|
6152
6132
|
const argPath = process.argv[3];
|
|
6153
6133
|
if (argPath && !argPath.startsWith("-")) {
|
|
@@ -6202,7 +6182,8 @@ var upload_default = async (options) => {
|
|
|
6202
6182
|
let result;
|
|
6203
6183
|
try {
|
|
6204
6184
|
result = await uploadPath(absolutePath, {
|
|
6205
|
-
projectName: APP_CONFIG.pinmeProjectName
|
|
6185
|
+
projectName: APP_CONFIG.pinmeProjectName,
|
|
6186
|
+
uid: authConfig == null ? void 0 : authConfig.address
|
|
6206
6187
|
});
|
|
6207
6188
|
} catch (error) {
|
|
6208
6189
|
console.error(import_chalk5.default.red(`Upload error: ${error.message}`));
|
|
@@ -6295,7 +6276,8 @@ var upload_default = async (options) => {
|
|
|
6295
6276
|
let result;
|
|
6296
6277
|
try {
|
|
6297
6278
|
result = await uploadPath(absolutePath, {
|
|
6298
|
-
projectName: APP_CONFIG.pinmeProjectName
|
|
6279
|
+
projectName: APP_CONFIG.pinmeProjectName,
|
|
6280
|
+
uid: authConfig == null ? void 0 : authConfig.address
|
|
6299
6281
|
});
|
|
6300
6282
|
} catch (error) {
|
|
6301
6283
|
console.error(import_chalk5.default.red(`Upload error: ${error.message}`));
|
|
@@ -6336,7 +6318,7 @@ var upload_default = async (options) => {
|
|
|
6336
6318
|
};
|
|
6337
6319
|
|
|
6338
6320
|
// bin/importCar.ts
|
|
6339
|
-
var
|
|
6321
|
+
var import_path7 = __toESM(require("path"));
|
|
6340
6322
|
var import_chalk6 = __toESM(require("chalk"));
|
|
6341
6323
|
var import_inquirer2 = __toESM(require("inquirer"));
|
|
6342
6324
|
var import_figlet2 = __toESM(require("figlet"));
|
|
@@ -6359,7 +6341,7 @@ function encryptHash2(contentHash, key, uid) {
|
|
|
6359
6341
|
}
|
|
6360
6342
|
function checkPathSync2(inputPath) {
|
|
6361
6343
|
try {
|
|
6362
|
-
const absolutePath =
|
|
6344
|
+
const absolutePath = import_path7.default.resolve(inputPath);
|
|
6363
6345
|
if (import_fs3.default.existsSync(absolutePath)) {
|
|
6364
6346
|
return absolutePath;
|
|
6365
6347
|
}
|
|
@@ -6413,7 +6395,10 @@ var importCar_default = async (options) => {
|
|
|
6413
6395
|
}
|
|
6414
6396
|
console.log(import_chalk6.default.blue(`importing ${absolutePath} to ipfs as CAR...`));
|
|
6415
6397
|
try {
|
|
6416
|
-
const result = await uploadPath(absolutePath, {
|
|
6398
|
+
const result = await uploadPath(absolutePath, {
|
|
6399
|
+
importAsCar: true,
|
|
6400
|
+
uid: getUid2()
|
|
6401
|
+
});
|
|
6417
6402
|
if (result) {
|
|
6418
6403
|
const uid = getUid2();
|
|
6419
6404
|
const encryptedCID = encryptHash2(result.contentHash, APP_CONFIG.secretKey, uid);
|
|
@@ -6464,7 +6449,10 @@ var importCar_default = async (options) => {
|
|
|
6464
6449
|
}
|
|
6465
6450
|
console.log(import_chalk6.default.blue(`importing ${absolutePath} to ipfs as CAR...`));
|
|
6466
6451
|
try {
|
|
6467
|
-
const result = await uploadPath(absolutePath, {
|
|
6452
|
+
const result = await uploadPath(absolutePath, {
|
|
6453
|
+
importAsCar: true,
|
|
6454
|
+
uid: getUid2()
|
|
6455
|
+
});
|
|
6468
6456
|
if (result) {
|
|
6469
6457
|
const uid = getUid2();
|
|
6470
6458
|
const encryptedCID = encryptHash2(result.contentHash, APP_CONFIG.secretKey, uid);
|
|
@@ -6499,7 +6487,7 @@ var importCar_default = async (options) => {
|
|
|
6499
6487
|
};
|
|
6500
6488
|
|
|
6501
6489
|
// bin/exportCar.ts
|
|
6502
|
-
var
|
|
6490
|
+
var import_path8 = __toESM(require("path"));
|
|
6503
6491
|
var import_chalk7 = __toESM(require("chalk"));
|
|
6504
6492
|
var import_inquirer3 = __toESM(require("inquirer"));
|
|
6505
6493
|
var import_figlet3 = __toESM(require("figlet"));
|
|
@@ -6639,14 +6627,14 @@ var exportCar_default = async () => {
|
|
|
6639
6627
|
]);
|
|
6640
6628
|
outputDir = answer.output.trim() || currentDir;
|
|
6641
6629
|
}
|
|
6642
|
-
outputDir =
|
|
6630
|
+
outputDir = import_path8.default.resolve(outputDir);
|
|
6643
6631
|
if (!import_fs4.default.existsSync(outputDir)) {
|
|
6644
6632
|
import_fs4.default.mkdirSync(outputDir, { recursive: true });
|
|
6645
6633
|
} else if (!import_fs4.default.statSync(outputDir).isDirectory()) {
|
|
6646
6634
|
console.log(import_chalk7.default.red(`Error: ${outputDir} exists but is not a directory.`));
|
|
6647
6635
|
return;
|
|
6648
6636
|
}
|
|
6649
|
-
const finalOutputPath =
|
|
6637
|
+
const finalOutputPath = import_path8.default.join(outputDir, `${cid}.car`);
|
|
6650
6638
|
if (import_fs4.default.existsSync(finalOutputPath)) {
|
|
6651
6639
|
const answer = await import_inquirer3.default.prompt([
|
|
6652
6640
|
{
|
|
@@ -7075,7 +7063,7 @@ async function walletBalanceCmd() {
|
|
|
7075
7063
|
}
|
|
7076
7064
|
|
|
7077
7065
|
// bin/bind.ts
|
|
7078
|
-
var
|
|
7066
|
+
var import_path9 = __toESM(require("path"));
|
|
7079
7067
|
var import_chalk15 = __toESM(require("chalk"));
|
|
7080
7068
|
var import_inquirer7 = __toESM(require("inquirer"));
|
|
7081
7069
|
function parseArgs() {
|
|
@@ -7174,9 +7162,9 @@ async function bindCmd() {
|
|
|
7174
7162
|
}
|
|
7175
7163
|
throw e;
|
|
7176
7164
|
}
|
|
7177
|
-
const absolutePath =
|
|
7165
|
+
const absolutePath = import_path9.default.resolve(targetPath);
|
|
7178
7166
|
console.log(import_chalk15.default.blue(`Uploading: ${absolutePath}`));
|
|
7179
|
-
const up = await uploadPath(absolutePath);
|
|
7167
|
+
const up = await uploadPath(absolutePath, { uid: authConfig.address });
|
|
7180
7168
|
if (!(up == null ? void 0 : up.contentHash)) {
|
|
7181
7169
|
console.log(import_chalk15.default.red("Upload failed, binding aborted."));
|
|
7182
7170
|
return;
|
|
@@ -7251,19 +7239,19 @@ Login failed: ${(e == null ? void 0 : e.message) || e}`));
|
|
|
7251
7239
|
|
|
7252
7240
|
// bin/create.ts
|
|
7253
7241
|
var import_chalk19 = __toESM(require("chalk"));
|
|
7254
|
-
var
|
|
7255
|
-
var
|
|
7242
|
+
var import_fs_extra6 = __toESM(require("fs-extra"));
|
|
7243
|
+
var import_path11 = __toESM(require("path"));
|
|
7256
7244
|
var import_inquirer8 = __toESM(require("inquirer"));
|
|
7257
7245
|
var import_child_process3 = require("child_process");
|
|
7258
7246
|
|
|
7259
7247
|
// bin/utils/installProjectDependencies.ts
|
|
7260
|
-
var
|
|
7261
|
-
var
|
|
7262
|
-
var
|
|
7248
|
+
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
7249
|
+
var import_os4 = __toESM(require("os"));
|
|
7250
|
+
var import_path10 = __toESM(require("path"));
|
|
7263
7251
|
var import_chalk17 = __toESM(require("chalk"));
|
|
7264
7252
|
var import_child_process2 = require("child_process");
|
|
7265
7253
|
function makeTempCacheDir() {
|
|
7266
|
-
return
|
|
7254
|
+
return import_fs_extra5.default.mkdtempSync(import_path10.default.join(import_os4.default.tmpdir(), "pinme-npm-cache-"));
|
|
7267
7255
|
}
|
|
7268
7256
|
function runInstall(cwd, cacheDir) {
|
|
7269
7257
|
(0, import_child_process2.execFileSync)("npm", ["install", "--cache", cacheDir, "--no-audit", "--no-fund"], {
|
|
@@ -7290,7 +7278,7 @@ function installProjectDependencies(cwd) {
|
|
|
7290
7278
|
} catch (error) {
|
|
7291
7279
|
lastError = error;
|
|
7292
7280
|
} finally {
|
|
7293
|
-
|
|
7281
|
+
import_fs_extra5.default.removeSync(cacheDir);
|
|
7294
7282
|
}
|
|
7295
7283
|
}
|
|
7296
7284
|
throw lastError;
|
|
@@ -7473,7 +7461,7 @@ ${configExport}
|
|
|
7473
7461
|
`;
|
|
7474
7462
|
}
|
|
7475
7463
|
function resolveExtractedTemplateDir(extractDir) {
|
|
7476
|
-
const entries =
|
|
7464
|
+
const entries = import_fs_extra6.default.readdirSync(extractDir, { withFileTypes: true });
|
|
7477
7465
|
const templateDir = entries.find((entry) => entry.isDirectory() && entry.name.startsWith(`${TEMPLATE_REPO_NAME}-`));
|
|
7478
7466
|
if (!templateDir) {
|
|
7479
7467
|
throw createConfigError("Downloaded template archive structure is invalid.", [
|
|
@@ -7481,10 +7469,10 @@ function resolveExtractedTemplateDir(extractDir) {
|
|
|
7481
7469
|
`Template branch: ${TEMPLATE_BRANCH}`
|
|
7482
7470
|
]);
|
|
7483
7471
|
}
|
|
7484
|
-
return
|
|
7472
|
+
return import_path11.default.join(extractDir, templateDir.name);
|
|
7485
7473
|
}
|
|
7486
7474
|
function updateFrontendUrlInConfig(configPath, frontendUrl) {
|
|
7487
|
-
let config =
|
|
7475
|
+
let config = import_fs_extra6.default.readFileSync(configPath, "utf-8");
|
|
7488
7476
|
if (config.includes("frontend_url")) {
|
|
7489
7477
|
config = config.replace(
|
|
7490
7478
|
/frontend_url\s*=\s*"[^"]*"/,
|
|
@@ -7497,7 +7485,7 @@ function updateFrontendUrlInConfig(configPath, frontendUrl) {
|
|
|
7497
7485
|
`
|
|
7498
7486
|
);
|
|
7499
7487
|
}
|
|
7500
|
-
|
|
7488
|
+
import_fs_extra6.default.writeFileSync(configPath, config);
|
|
7501
7489
|
}
|
|
7502
7490
|
async function createCmd(options) {
|
|
7503
7491
|
var _a2, _b;
|
|
@@ -7527,8 +7515,8 @@ async function createCmd(options) {
|
|
|
7527
7515
|
]);
|
|
7528
7516
|
projectName = answers.projectName;
|
|
7529
7517
|
}
|
|
7530
|
-
const targetDir =
|
|
7531
|
-
if (
|
|
7518
|
+
const targetDir = import_path11.default.join(PROJECT_DIR, projectName);
|
|
7519
|
+
if (import_fs_extra6.default.existsSync(targetDir) && !options.force) {
|
|
7532
7520
|
console.log(import_chalk19.default.yellow(`
|
|
7533
7521
|
Directory "${projectName}" already exists.`));
|
|
7534
7522
|
const answers = await import_inquirer8.default.prompt([
|
|
@@ -7543,7 +7531,7 @@ Directory "${projectName}" already exists.`));
|
|
|
7543
7531
|
console.log(import_chalk19.default.gray("Cancelled."));
|
|
7544
7532
|
process.exit(0);
|
|
7545
7533
|
}
|
|
7546
|
-
|
|
7534
|
+
import_fs_extra6.default.removeSync(targetDir);
|
|
7547
7535
|
}
|
|
7548
7536
|
console.log(import_chalk19.default.blue("\n1. Creating worker and database..."));
|
|
7549
7537
|
const apiUrl = getPinmeApiUrl("/create_worker");
|
|
@@ -7578,8 +7566,8 @@ Directory "${projectName}" already exists.`));
|
|
|
7578
7566
|
]);
|
|
7579
7567
|
}
|
|
7580
7568
|
console.log(import_chalk19.default.blue("\n2. Downloading template from repository..."));
|
|
7581
|
-
const zipPath =
|
|
7582
|
-
const extractDir =
|
|
7569
|
+
const zipPath = import_path11.default.join(PROJECT_DIR, "template.zip");
|
|
7570
|
+
const extractDir = import_path11.default.join(PROJECT_DIR, `.pinme-template-${Date.now()}`);
|
|
7583
7571
|
const templateZipUrl = getTemplateZipUrl(TEMPLATE_BRANCH);
|
|
7584
7572
|
let downloadSuccess = false;
|
|
7585
7573
|
console.log(import_chalk19.default.gray(` Template branch: ${TEMPLATE_BRANCH}`));
|
|
@@ -7589,14 +7577,14 @@ Directory "${projectName}" already exists.`));
|
|
|
7589
7577
|
(0, import_child_process3.execSync)(`curl -L --retry 3 --retry-delay 2 -o "${zipPath}" "${templateZipUrl}"`, {
|
|
7590
7578
|
stdio: "inherit"
|
|
7591
7579
|
});
|
|
7592
|
-
if (!
|
|
7580
|
+
if (!import_fs_extra6.default.existsSync(zipPath) || import_fs_extra6.default.statSync(zipPath).size < 100) {
|
|
7593
7581
|
throw new Error("Downloaded file is too small or empty");
|
|
7594
7582
|
}
|
|
7595
7583
|
downloadSuccess = true;
|
|
7596
7584
|
} catch (downloadError) {
|
|
7597
7585
|
console.log(import_chalk19.default.yellow(` Attempt ${attempt} failed: ${downloadError.message}`));
|
|
7598
|
-
if (
|
|
7599
|
-
|
|
7586
|
+
if (import_fs_extra6.default.existsSync(zipPath)) {
|
|
7587
|
+
import_fs_extra6.default.removeSync(zipPath);
|
|
7600
7588
|
}
|
|
7601
7589
|
if (attempt === 3) {
|
|
7602
7590
|
throw new Error(`Failed to download template after 3 attempts: ${downloadError.message}`);
|
|
@@ -7604,32 +7592,32 @@ Directory "${projectName}" already exists.`));
|
|
|
7604
7592
|
}
|
|
7605
7593
|
}
|
|
7606
7594
|
try {
|
|
7607
|
-
|
|
7595
|
+
import_fs_extra6.default.ensureDirSync(extractDir);
|
|
7608
7596
|
(0, import_child_process3.execSync)(`unzip -o "${zipPath}" -d "${extractDir}"`, {
|
|
7609
7597
|
stdio: "inherit"
|
|
7610
7598
|
});
|
|
7611
7599
|
const subDir = resolveExtractedTemplateDir(extractDir);
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
const nodeModulesPath =
|
|
7616
|
-
const packageLockPath =
|
|
7617
|
-
if (
|
|
7600
|
+
import_fs_extra6.default.copySync(subDir, targetDir);
|
|
7601
|
+
import_fs_extra6.default.removeSync(zipPath);
|
|
7602
|
+
import_fs_extra6.default.removeSync(extractDir);
|
|
7603
|
+
const nodeModulesPath = import_path11.default.join(targetDir, "node_modules");
|
|
7604
|
+
const packageLockPath = import_path11.default.join(targetDir, "package-lock.json");
|
|
7605
|
+
if (import_fs_extra6.default.existsSync(nodeModulesPath)) {
|
|
7618
7606
|
console.log(import_chalk19.default.gray(" Removing existing node_modules..."));
|
|
7619
|
-
|
|
7607
|
+
import_fs_extra6.default.removeSync(nodeModulesPath);
|
|
7620
7608
|
}
|
|
7621
|
-
if (
|
|
7609
|
+
if (import_fs_extra6.default.existsSync(packageLockPath)) {
|
|
7622
7610
|
console.log(import_chalk19.default.gray(" Removing existing package-lock.json..."));
|
|
7623
|
-
|
|
7624
|
-
}
|
|
7625
|
-
const frontendNodeModules =
|
|
7626
|
-
const backendNodeModules =
|
|
7627
|
-
const frontendPackageLock =
|
|
7628
|
-
const backendPackageLock =
|
|
7629
|
-
if (
|
|
7630
|
-
if (
|
|
7631
|
-
if (
|
|
7632
|
-
if (
|
|
7611
|
+
import_fs_extra6.default.removeSync(packageLockPath);
|
|
7612
|
+
}
|
|
7613
|
+
const frontendNodeModules = import_path11.default.join(targetDir, "frontend", "node_modules");
|
|
7614
|
+
const backendNodeModules = import_path11.default.join(targetDir, "backend", "node_modules");
|
|
7615
|
+
const frontendPackageLock = import_path11.default.join(targetDir, "frontend", "package-lock.json");
|
|
7616
|
+
const backendPackageLock = import_path11.default.join(targetDir, "backend", "package-lock.json");
|
|
7617
|
+
if (import_fs_extra6.default.existsSync(frontendNodeModules)) import_fs_extra6.default.removeSync(frontendNodeModules);
|
|
7618
|
+
if (import_fs_extra6.default.existsSync(backendNodeModules)) import_fs_extra6.default.removeSync(backendNodeModules);
|
|
7619
|
+
if (import_fs_extra6.default.existsSync(frontendPackageLock)) import_fs_extra6.default.removeSync(frontendPackageLock);
|
|
7620
|
+
if (import_fs_extra6.default.existsSync(backendPackageLock)) import_fs_extra6.default.removeSync(backendPackageLock);
|
|
7633
7621
|
console.log(import_chalk19.default.green(` Template downloaded to: ${targetDir}`));
|
|
7634
7622
|
} catch (error) {
|
|
7635
7623
|
throw createCommandError("template extraction", `unzip -o "${zipPath}" -d "${PROJECT_DIR}"`, error, [
|
|
@@ -7637,58 +7625,58 @@ Directory "${projectName}" already exists.`));
|
|
|
7637
7625
|
]);
|
|
7638
7626
|
}
|
|
7639
7627
|
console.log(import_chalk19.default.blue("\n3. Updating configuration..."));
|
|
7640
|
-
const configPath =
|
|
7641
|
-
const config =
|
|
7628
|
+
const configPath = import_path11.default.join(targetDir, "pinme.toml");
|
|
7629
|
+
const config = import_fs_extra6.default.readFileSync(configPath, "utf-8");
|
|
7642
7630
|
let updatedConfig = config.replace(
|
|
7643
7631
|
/project_name = ".*"/,
|
|
7644
7632
|
`project_name = "${workerData.project_name}"`
|
|
7645
7633
|
);
|
|
7646
|
-
|
|
7634
|
+
import_fs_extra6.default.writeFileSync(configPath, updatedConfig);
|
|
7647
7635
|
console.log(import_chalk19.default.green(` Updated pinme.toml`));
|
|
7648
7636
|
console.log(import_chalk19.default.gray(` metadata: ${workerData.metadata}`));
|
|
7649
|
-
const backendDir =
|
|
7650
|
-
if (
|
|
7637
|
+
const backendDir = import_path11.default.join(targetDir, "backend");
|
|
7638
|
+
if (import_fs_extra6.default.existsSync(backendDir) && workerData.metadata) {
|
|
7651
7639
|
const metadataContent = typeof workerData.metadata === "string" ? workerData.metadata : JSON.stringify(workerData.metadata, null, 2);
|
|
7652
|
-
|
|
7653
|
-
|
|
7640
|
+
import_fs_extra6.default.writeFileSync(
|
|
7641
|
+
import_path11.default.join(backendDir, "metadata.json"),
|
|
7654
7642
|
metadataContent
|
|
7655
7643
|
);
|
|
7656
7644
|
console.log(import_chalk19.default.green(` Saved metadata.json`));
|
|
7657
7645
|
}
|
|
7658
|
-
const wranglerPath =
|
|
7659
|
-
if (
|
|
7660
|
-
let wranglerContent =
|
|
7646
|
+
const wranglerPath = import_path11.default.join(backendDir, "wrangler.toml");
|
|
7647
|
+
if (import_fs_extra6.default.existsSync(wranglerPath) && workerData.api_key) {
|
|
7648
|
+
let wranglerContent = import_fs_extra6.default.readFileSync(wranglerPath, "utf-8");
|
|
7661
7649
|
wranglerContent = wranglerContent.replace(
|
|
7662
7650
|
/^name = ".*"$/m,
|
|
7663
7651
|
`name = "${workerData.project_name}"`
|
|
7664
7652
|
);
|
|
7665
|
-
|
|
7653
|
+
import_fs_extra6.default.writeFileSync(wranglerPath, wranglerContent);
|
|
7666
7654
|
console.log(import_chalk19.default.green(` Updated backend/wrangler.toml API_KEY`));
|
|
7667
7655
|
}
|
|
7668
|
-
const frontendConfigPath =
|
|
7656
|
+
const frontendConfigPath = import_path11.default.join(targetDir, "frontend", "src", "utils", "config.ts");
|
|
7669
7657
|
if (workerData.public_client_config) {
|
|
7670
|
-
const frontendConfigContent =
|
|
7671
|
-
|
|
7672
|
-
|
|
7658
|
+
const frontendConfigContent = import_fs_extra6.default.existsSync(frontendConfigPath) ? import_fs_extra6.default.readFileSync(frontendConfigPath, "utf-8") : "";
|
|
7659
|
+
import_fs_extra6.default.ensureDirSync(import_path11.default.dirname(frontendConfigPath));
|
|
7660
|
+
import_fs_extra6.default.writeFileSync(
|
|
7673
7661
|
frontendConfigPath,
|
|
7674
7662
|
injectPublicClientConfigIntoFile(frontendConfigContent, workerData.public_client_config)
|
|
7675
7663
|
);
|
|
7676
7664
|
console.log(import_chalk19.default.green(` Updated frontend/src/utils/config.ts public_client_config`));
|
|
7677
7665
|
}
|
|
7678
|
-
const envExamplePath =
|
|
7679
|
-
const envPath =
|
|
7680
|
-
if (
|
|
7681
|
-
let envContent =
|
|
7666
|
+
const envExamplePath = import_path11.default.join(targetDir, "frontend", ".env.example");
|
|
7667
|
+
const envPath = import_path11.default.join(targetDir, "frontend", ".env");
|
|
7668
|
+
if (import_fs_extra6.default.existsSync(envExamplePath)) {
|
|
7669
|
+
let envContent = import_fs_extra6.default.readFileSync(envExamplePath, "utf-8");
|
|
7682
7670
|
envContent = envContent.replace(/your-project/g, workerData.project_name);
|
|
7683
7671
|
envContent = envContent.replace(
|
|
7684
7672
|
/^VITE_API_URL=.*$/m,
|
|
7685
7673
|
`VITE_API_URL=${workerData.api_domain}`
|
|
7686
7674
|
);
|
|
7687
|
-
|
|
7675
|
+
import_fs_extra6.default.writeFileSync(envPath, envContent);
|
|
7688
7676
|
console.log(import_chalk19.default.green(` Created frontend/.env file`));
|
|
7689
7677
|
console.log(import_chalk19.default.gray(` VITE_API_URL: ${workerData.api_domain}`));
|
|
7690
7678
|
}
|
|
7691
|
-
let pinmeConfig =
|
|
7679
|
+
let pinmeConfig = import_fs_extra6.default.readFileSync(configPath, "utf-8");
|
|
7692
7680
|
if (pinmeConfig.includes("api_url")) {
|
|
7693
7681
|
pinmeConfig = pinmeConfig.replace(
|
|
7694
7682
|
/api_url\s*=\s*"[^"]*"/,
|
|
@@ -7705,7 +7693,7 @@ Directory "${projectName}" already exists.`));
|
|
|
7705
7693
|
}
|
|
7706
7694
|
pinmeConfig = newLines.join("\n");
|
|
7707
7695
|
}
|
|
7708
|
-
|
|
7696
|
+
import_fs_extra6.default.writeFileSync(configPath, pinmeConfig);
|
|
7709
7697
|
console.log(import_chalk19.default.green(` Updated pinme.toml with api_url`));
|
|
7710
7698
|
console.log(import_chalk19.default.blue("\n4. Installing dependencies..."));
|
|
7711
7699
|
try {
|
|
@@ -7761,26 +7749,26 @@ Directory "${projectName}" already exists.`));
|
|
|
7761
7749
|
"Fix the build error shown above, then rerun `pinme create`."
|
|
7762
7750
|
]);
|
|
7763
7751
|
}
|
|
7764
|
-
const distWorkerDir =
|
|
7765
|
-
const workerJsPath =
|
|
7766
|
-
if (!
|
|
7752
|
+
const distWorkerDir = import_path11.default.join(targetDir, "dist-worker");
|
|
7753
|
+
const workerJsPath = import_path11.default.join(distWorkerDir, "worker.js");
|
|
7754
|
+
if (!import_fs_extra6.default.existsSync(distWorkerDir) || !import_fs_extra6.default.existsSync(workerJsPath)) {
|
|
7767
7755
|
throw createConfigError("Built worker output not found: `dist-worker/worker.js`.", [
|
|
7768
7756
|
"Make sure `npm run build:worker` completed successfully."
|
|
7769
7757
|
]);
|
|
7770
7758
|
}
|
|
7771
7759
|
const modulePaths = [];
|
|
7772
|
-
const files =
|
|
7760
|
+
const files = import_fs_extra6.default.readdirSync(distWorkerDir);
|
|
7773
7761
|
for (const file of files) {
|
|
7774
7762
|
if (file.endsWith(".js") && file !== "worker.js") {
|
|
7775
|
-
modulePaths.push(
|
|
7763
|
+
modulePaths.push(import_path11.default.join(distWorkerDir, file));
|
|
7776
7764
|
}
|
|
7777
7765
|
}
|
|
7778
|
-
const sqlDir =
|
|
7766
|
+
const sqlDir = import_path11.default.join(targetDir, "db");
|
|
7779
7767
|
const sqlFiles = [];
|
|
7780
|
-
if (
|
|
7781
|
-
const sqlFileNames =
|
|
7768
|
+
if (import_fs_extra6.default.existsSync(sqlDir)) {
|
|
7769
|
+
const sqlFileNames = import_fs_extra6.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
|
|
7782
7770
|
for (const filename of sqlFileNames) {
|
|
7783
|
-
sqlFiles.push(
|
|
7771
|
+
sqlFiles.push(import_path11.default.join(sqlDir, filename));
|
|
7784
7772
|
console.log(import_chalk19.default.gray(` Including SQL: ${filename}`));
|
|
7785
7773
|
}
|
|
7786
7774
|
}
|
|
@@ -7795,20 +7783,20 @@ Directory "${projectName}" already exists.`));
|
|
|
7795
7783
|
formData.append("metadata", new Blob2([metadataContent], {
|
|
7796
7784
|
type: "application/json"
|
|
7797
7785
|
}), "metadata.json");
|
|
7798
|
-
const workerCode =
|
|
7786
|
+
const workerCode = import_fs_extra6.default.readFileSync(workerJsPath, "utf-8");
|
|
7799
7787
|
formData.append("worker.js", new Blob2([workerCode], {
|
|
7800
7788
|
type: "application/javascript+module"
|
|
7801
7789
|
}), "worker.js");
|
|
7802
7790
|
for (const modulePath of modulePaths) {
|
|
7803
|
-
const filename =
|
|
7804
|
-
const content =
|
|
7791
|
+
const filename = import_path11.default.basename(modulePath);
|
|
7792
|
+
const content = import_fs_extra6.default.readFileSync(modulePath, "utf-8");
|
|
7805
7793
|
formData.append(filename, new Blob2([content], {
|
|
7806
7794
|
type: "application/javascript+module"
|
|
7807
7795
|
}), filename);
|
|
7808
7796
|
}
|
|
7809
7797
|
for (const sqlFile of sqlFiles) {
|
|
7810
|
-
const filename =
|
|
7811
|
-
const content =
|
|
7798
|
+
const filename = import_path11.default.basename(sqlFile);
|
|
7799
|
+
const content = import_fs_extra6.default.readFileSync(sqlFile, "utf-8");
|
|
7812
7800
|
formData.append("sql_file", new Blob2([content], {
|
|
7813
7801
|
type: "application/sql"
|
|
7814
7802
|
}), filename);
|
|
@@ -7841,8 +7829,8 @@ Directory "${projectName}" already exists.`));
|
|
|
7841
7829
|
]);
|
|
7842
7830
|
}
|
|
7843
7831
|
console.log(import_chalk19.default.blue("\n7. Building frontend..."));
|
|
7844
|
-
const frontendDir =
|
|
7845
|
-
if (
|
|
7832
|
+
const frontendDir = import_path11.default.join(targetDir, "frontend");
|
|
7833
|
+
if (import_fs_extra6.default.existsSync(frontendDir)) {
|
|
7846
7834
|
try {
|
|
7847
7835
|
(0, import_child_process3.execSync)("npm run build:frontend", {
|
|
7848
7836
|
cwd: targetDir,
|
|
@@ -7856,12 +7844,13 @@ Directory "${projectName}" already exists.`));
|
|
|
7856
7844
|
}
|
|
7857
7845
|
console.log(import_chalk19.default.blue(" Uploading to IPFS..."));
|
|
7858
7846
|
try {
|
|
7859
|
-
const uploadResult = await uploadPath(
|
|
7860
|
-
projectName: workerData.project_name
|
|
7847
|
+
const uploadResult = await uploadPath(import_path11.default.join(frontendDir, "dist"), {
|
|
7848
|
+
projectName: workerData.project_name,
|
|
7849
|
+
uid: headers["token-address"]
|
|
7861
7850
|
});
|
|
7862
7851
|
console.log(import_chalk19.default.green(` Frontend uploaded to IPFS: ${uploadResult.publicUrl}`));
|
|
7863
7852
|
updateFrontendUrlInConfig(
|
|
7864
|
-
|
|
7853
|
+
import_path11.default.join(targetDir, "pinme.toml"),
|
|
7865
7854
|
uploadResult.publicUrl
|
|
7866
7855
|
);
|
|
7867
7856
|
console.log(import_chalk19.default.green(" Updated pinme.toml with frontend URL"));
|
|
@@ -7887,31 +7876,31 @@ Next steps:`));
|
|
|
7887
7876
|
|
|
7888
7877
|
// bin/save.ts
|
|
7889
7878
|
var import_chalk20 = __toESM(require("chalk"));
|
|
7890
|
-
var
|
|
7891
|
-
var
|
|
7879
|
+
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
7880
|
+
var import_path12 = __toESM(require("path"));
|
|
7892
7881
|
var import_child_process4 = require("child_process");
|
|
7893
7882
|
var PROJECT_DIR2 = process.cwd();
|
|
7894
7883
|
function loadConfig() {
|
|
7895
|
-
const configPath =
|
|
7896
|
-
if (!
|
|
7884
|
+
const configPath = import_path12.default.join(PROJECT_DIR2, "pinme.toml");
|
|
7885
|
+
if (!import_fs_extra7.default.existsSync(configPath)) {
|
|
7897
7886
|
throw createConfigError("`pinme.toml` not found in the current directory.", [
|
|
7898
7887
|
"Run this command from the Pinme project root.",
|
|
7899
7888
|
"If the project has not been initialized yet, create or restore `pinme.toml` first."
|
|
7900
7889
|
]);
|
|
7901
7890
|
}
|
|
7902
|
-
const configContent =
|
|
7891
|
+
const configContent = import_fs_extra7.default.readFileSync(configPath, "utf-8");
|
|
7903
7892
|
const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
|
|
7904
7893
|
return {
|
|
7905
7894
|
project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
|
|
7906
7895
|
};
|
|
7907
7896
|
}
|
|
7908
7897
|
function getMetadata() {
|
|
7909
|
-
const metadataPath =
|
|
7910
|
-
if (!
|
|
7898
|
+
const metadataPath = import_path12.default.join(PROJECT_DIR2, "backend", "metadata.json");
|
|
7899
|
+
if (!import_fs_extra7.default.existsSync(metadataPath)) {
|
|
7911
7900
|
console.log(import_chalk20.default.yellow(" Warning: metadata.json not found, using empty metadata"));
|
|
7912
7901
|
return {};
|
|
7913
7902
|
}
|
|
7914
|
-
return
|
|
7903
|
+
return import_fs_extra7.default.readJsonSync(metadataPath);
|
|
7915
7904
|
}
|
|
7916
7905
|
function buildWorker() {
|
|
7917
7906
|
console.log(import_chalk20.default.blue("Building worker..."));
|
|
@@ -7972,34 +7961,34 @@ function installDependencies() {
|
|
|
7972
7961
|
}
|
|
7973
7962
|
}
|
|
7974
7963
|
function getBuiltWorker() {
|
|
7975
|
-
const distWorkerDir =
|
|
7976
|
-
if (!
|
|
7964
|
+
const distWorkerDir = import_path12.default.join(PROJECT_DIR2, "dist-worker");
|
|
7965
|
+
if (!import_fs_extra7.default.existsSync(distWorkerDir)) {
|
|
7977
7966
|
throw createConfigError("Built worker output not found: `dist-worker/`.", [
|
|
7978
7967
|
"Make sure `npm run build:worker` completed successfully."
|
|
7979
7968
|
]);
|
|
7980
7969
|
}
|
|
7981
|
-
const workerJsPath =
|
|
7982
|
-
if (!
|
|
7970
|
+
const workerJsPath = import_path12.default.join(distWorkerDir, "worker.js");
|
|
7971
|
+
if (!import_fs_extra7.default.existsSync(workerJsPath)) {
|
|
7983
7972
|
throw createConfigError("Built worker entry file not found: `dist-worker/worker.js`.", [
|
|
7984
7973
|
"Check the worker build output and bundler config."
|
|
7985
7974
|
]);
|
|
7986
7975
|
}
|
|
7987
7976
|
const modulePaths = [];
|
|
7988
|
-
const files =
|
|
7977
|
+
const files = import_fs_extra7.default.readdirSync(distWorkerDir);
|
|
7989
7978
|
for (const file of files) {
|
|
7990
7979
|
if (file.endsWith(".js") && file !== "worker.js") {
|
|
7991
|
-
modulePaths.push(
|
|
7980
|
+
modulePaths.push(import_path12.default.join(distWorkerDir, file));
|
|
7992
7981
|
}
|
|
7993
7982
|
}
|
|
7994
7983
|
return { workerJsPath, modulePaths };
|
|
7995
7984
|
}
|
|
7996
7985
|
function getSqlFiles() {
|
|
7997
|
-
const sqlDir =
|
|
7998
|
-
if (!
|
|
7986
|
+
const sqlDir = import_path12.default.join(PROJECT_DIR2, "db");
|
|
7987
|
+
if (!import_fs_extra7.default.existsSync(sqlDir)) {
|
|
7999
7988
|
return [];
|
|
8000
7989
|
}
|
|
8001
|
-
const files =
|
|
8002
|
-
return files.map((f) =>
|
|
7990
|
+
const files = import_fs_extra7.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
|
|
7991
|
+
return files.map((f) => import_path12.default.join(sqlDir, f));
|
|
8003
7992
|
}
|
|
8004
7993
|
async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, projectName) {
|
|
8005
7994
|
var _a2, _b;
|
|
@@ -8019,20 +8008,20 @@ async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, project
|
|
|
8019
8008
|
formData.append("metadata", new Blob2([JSON.stringify(metadata)], {
|
|
8020
8009
|
type: "application/json"
|
|
8021
8010
|
}), "metadata.json");
|
|
8022
|
-
const workerCode =
|
|
8011
|
+
const workerCode = import_fs_extra7.default.readFileSync(workerJsPath, "utf-8");
|
|
8023
8012
|
formData.append("worker.js", new Blob2([workerCode], {
|
|
8024
8013
|
type: "application/javascript+module"
|
|
8025
8014
|
}), "worker.js");
|
|
8026
8015
|
for (const modulePath of modulePaths) {
|
|
8027
|
-
const filename =
|
|
8028
|
-
const content =
|
|
8016
|
+
const filename = import_path12.default.basename(modulePath);
|
|
8017
|
+
const content = import_fs_extra7.default.readFileSync(modulePath, "utf-8");
|
|
8029
8018
|
formData.append(filename, new Blob2([content], {
|
|
8030
8019
|
type: "application/javascript+module"
|
|
8031
8020
|
}), filename);
|
|
8032
8021
|
}
|
|
8033
8022
|
for (const sqlFile of sqlFiles) {
|
|
8034
|
-
const filename =
|
|
8035
|
-
const content =
|
|
8023
|
+
const filename = import_path12.default.basename(sqlFile);
|
|
8024
|
+
const content = import_fs_extra7.default.readFileSync(sqlFile, "utf-8");
|
|
8036
8025
|
formData.append("sql_file", new Blob2([content], {
|
|
8037
8026
|
type: "application/sql"
|
|
8038
8027
|
}), filename);
|
|
@@ -8082,7 +8071,7 @@ function buildFrontend() {
|
|
|
8082
8071
|
}
|
|
8083
8072
|
}
|
|
8084
8073
|
function updateFrontendUrlInConfig2(configPath, frontendUrl) {
|
|
8085
|
-
let config =
|
|
8074
|
+
let config = import_fs_extra7.default.readFileSync(configPath, "utf-8");
|
|
8086
8075
|
if (config.includes("frontend_url")) {
|
|
8087
8076
|
config = config.replace(
|
|
8088
8077
|
/frontend_url\s*=\s*"[^"]*"/,
|
|
@@ -8095,16 +8084,18 @@ function updateFrontendUrlInConfig2(configPath, frontendUrl) {
|
|
|
8095
8084
|
`
|
|
8096
8085
|
);
|
|
8097
8086
|
}
|
|
8098
|
-
|
|
8087
|
+
import_fs_extra7.default.writeFileSync(configPath, config);
|
|
8099
8088
|
}
|
|
8100
8089
|
async function deployFrontend(projectName) {
|
|
8101
8090
|
console.log(import_chalk20.default.blue("Deploying frontend to IPFS..."));
|
|
8102
8091
|
try {
|
|
8103
|
-
const
|
|
8104
|
-
|
|
8092
|
+
const headers = getAuthHeaders();
|
|
8093
|
+
const uploadResult = await uploadPath(import_path12.default.join(PROJECT_DIR2, "frontend", "dist"), {
|
|
8094
|
+
projectName,
|
|
8095
|
+
uid: headers["token-address"]
|
|
8105
8096
|
});
|
|
8106
8097
|
console.log(import_chalk20.default.green(`Frontend deployed to IPFS: ${uploadResult.publicUrl}`));
|
|
8107
|
-
updateFrontendUrlInConfig2(
|
|
8098
|
+
updateFrontendUrlInConfig2(import_path12.default.join(PROJECT_DIR2, "pinme.toml"), uploadResult.publicUrl);
|
|
8108
8099
|
console.log(import_chalk20.default.green("Updated pinme.toml with frontend URL"));
|
|
8109
8100
|
} catch (error) {
|
|
8110
8101
|
throw createCommandError("frontend deploy", "upload frontend/dist", error, [
|
|
@@ -8120,11 +8111,11 @@ async function saveCmd(options) {
|
|
|
8120
8111
|
"Run `pinme login` and retry."
|
|
8121
8112
|
]);
|
|
8122
8113
|
}
|
|
8123
|
-
const projectDir = options.projectName || options.name ?
|
|
8124
|
-
const tokenFileSrc =
|
|
8125
|
-
const tokenFileDst =
|
|
8126
|
-
if (
|
|
8127
|
-
|
|
8114
|
+
const projectDir = options.projectName || options.name ? import_path12.default.join(PROJECT_DIR2, options.projectName || options.name) : PROJECT_DIR2;
|
|
8115
|
+
const tokenFileSrc = import_path12.default.join(PROJECT_DIR2, ".token.json");
|
|
8116
|
+
const tokenFileDst = import_path12.default.join(projectDir, ".token.json");
|
|
8117
|
+
if (import_fs_extra7.default.existsSync(tokenFileSrc) && !import_fs_extra7.default.existsSync(tokenFileDst)) {
|
|
8118
|
+
import_fs_extra7.default.copySync(tokenFileSrc, tokenFileDst);
|
|
8128
8119
|
}
|
|
8129
8120
|
console.log(import_chalk20.default.blue("Deploying to platform...\n"));
|
|
8130
8121
|
console.log(import_chalk20.default.gray(`Project dir: ${PROJECT_DIR2}`));
|
|
@@ -8161,36 +8152,36 @@ async function saveCmd(options) {
|
|
|
8161
8152
|
|
|
8162
8153
|
// bin/updateDb.ts
|
|
8163
8154
|
var import_chalk21 = __toESM(require("chalk"));
|
|
8164
|
-
var
|
|
8165
|
-
var
|
|
8155
|
+
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
8156
|
+
var import_path13 = __toESM(require("path"));
|
|
8166
8157
|
var PROJECT_DIR3 = process.cwd();
|
|
8167
8158
|
function loadConfig2() {
|
|
8168
|
-
const configPath =
|
|
8169
|
-
if (!
|
|
8159
|
+
const configPath = import_path13.default.join(PROJECT_DIR3, "pinme.toml");
|
|
8160
|
+
if (!import_fs_extra8.default.existsSync(configPath)) {
|
|
8170
8161
|
throw createConfigError("`pinme.toml` not found in the current directory.", [
|
|
8171
8162
|
"Run this command from the Pinme project root."
|
|
8172
8163
|
]);
|
|
8173
8164
|
}
|
|
8174
|
-
const configContent =
|
|
8165
|
+
const configContent = import_fs_extra8.default.readFileSync(configPath, "utf-8");
|
|
8175
8166
|
const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
|
|
8176
8167
|
return {
|
|
8177
8168
|
project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
|
|
8178
8169
|
};
|
|
8179
8170
|
}
|
|
8180
8171
|
function getSqlFiles2() {
|
|
8181
|
-
const sqlDir =
|
|
8182
|
-
if (!
|
|
8172
|
+
const sqlDir = import_path13.default.join(PROJECT_DIR3, "db");
|
|
8173
|
+
if (!import_fs_extra8.default.existsSync(sqlDir)) {
|
|
8183
8174
|
throw createConfigError("SQL directory not found: `db/`.", [
|
|
8184
8175
|
"Create a `db/` directory and add at least one `.sql` migration file."
|
|
8185
8176
|
]);
|
|
8186
8177
|
}
|
|
8187
|
-
const files =
|
|
8178
|
+
const files = import_fs_extra8.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
|
|
8188
8179
|
if (files.length === 0) {
|
|
8189
8180
|
throw createConfigError("No `.sql` files were found in `db/`.", [
|
|
8190
8181
|
"Add one or more migration files before running `pinme update-db`."
|
|
8191
8182
|
]);
|
|
8192
8183
|
}
|
|
8193
|
-
return files.map((f) =>
|
|
8184
|
+
return files.map((f) => import_path13.default.join(sqlDir, f));
|
|
8194
8185
|
}
|
|
8195
8186
|
async function updateDb(sqlFiles, projectName) {
|
|
8196
8187
|
console.log(import_chalk21.default.blue("Importing SQL files to database..."));
|
|
@@ -8205,8 +8196,8 @@ async function updateDb(sqlFiles, projectName) {
|
|
|
8205
8196
|
const formData = new FormData4();
|
|
8206
8197
|
let totalSize = 0;
|
|
8207
8198
|
for (const sqlFile of sqlFiles) {
|
|
8208
|
-
const filename =
|
|
8209
|
-
const content =
|
|
8199
|
+
const filename = import_path13.default.basename(sqlFile);
|
|
8200
|
+
const content = import_fs_extra8.default.readFileSync(sqlFile);
|
|
8210
8201
|
totalSize += content.length;
|
|
8211
8202
|
if (totalSize > 10 * 1024 * 1024) {
|
|
8212
8203
|
throw createConfigError("Total SQL payload exceeds the 10MB platform limit.", [
|
|
@@ -8261,11 +8252,11 @@ async function updateDbCmd(options) {
|
|
|
8261
8252
|
"Run `pinme login` and retry."
|
|
8262
8253
|
]);
|
|
8263
8254
|
}
|
|
8264
|
-
const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ?
|
|
8265
|
-
const tokenFileSrc =
|
|
8266
|
-
const tokenFileDst =
|
|
8267
|
-
if (
|
|
8268
|
-
|
|
8255
|
+
const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path13.default.join(PROJECT_DIR3, options.projectName || options.name) : PROJECT_DIR3;
|
|
8256
|
+
const tokenFileSrc = import_path13.default.join(PROJECT_DIR3, ".token.json");
|
|
8257
|
+
const tokenFileDst = import_path13.default.join(projectDir, ".token.json");
|
|
8258
|
+
if (import_fs_extra8.default.existsSync(tokenFileSrc) && !import_fs_extra8.default.existsSync(tokenFileDst)) {
|
|
8259
|
+
import_fs_extra8.default.copySync(tokenFileSrc, tokenFileDst);
|
|
8269
8260
|
}
|
|
8270
8261
|
console.log(import_chalk21.default.blue("Importing SQL to database...\n"));
|
|
8271
8262
|
console.log(import_chalk21.default.gray(`Project dir: ${PROJECT_DIR3}`));
|
|
@@ -8290,31 +8281,31 @@ async function updateDbCmd(options) {
|
|
|
8290
8281
|
|
|
8291
8282
|
// bin/updateWorker.ts
|
|
8292
8283
|
var import_chalk22 = __toESM(require("chalk"));
|
|
8293
|
-
var
|
|
8294
|
-
var
|
|
8284
|
+
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
8285
|
+
var import_path14 = __toESM(require("path"));
|
|
8295
8286
|
var import_child_process5 = require("child_process");
|
|
8296
8287
|
var PROJECT_DIR4 = process.cwd();
|
|
8297
8288
|
function loadConfig3() {
|
|
8298
|
-
const configPath =
|
|
8299
|
-
if (!
|
|
8289
|
+
const configPath = import_path14.default.join(PROJECT_DIR4, "pinme.toml");
|
|
8290
|
+
if (!import_fs_extra9.default.existsSync(configPath)) {
|
|
8300
8291
|
throw createConfigError("`pinme.toml` not found in the current directory.", [
|
|
8301
8292
|
"Run this command from the Pinme project root."
|
|
8302
8293
|
]);
|
|
8303
8294
|
}
|
|
8304
|
-
const configContent =
|
|
8295
|
+
const configContent = import_fs_extra9.default.readFileSync(configPath, "utf-8");
|
|
8305
8296
|
const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
|
|
8306
8297
|
return {
|
|
8307
8298
|
project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
|
|
8308
8299
|
};
|
|
8309
8300
|
}
|
|
8310
8301
|
function getMetadata2() {
|
|
8311
|
-
const metadataPath =
|
|
8312
|
-
if (!
|
|
8302
|
+
const metadataPath = import_path14.default.join(PROJECT_DIR4, "backend", "metadata.json");
|
|
8303
|
+
if (!import_fs_extra9.default.existsSync(metadataPath)) {
|
|
8313
8304
|
throw createConfigError("`backend/metadata.json` not found.", [
|
|
8314
8305
|
"Create `backend/metadata.json` or restore it from the project template."
|
|
8315
8306
|
]);
|
|
8316
8307
|
}
|
|
8317
|
-
return
|
|
8308
|
+
return import_fs_extra9.default.readJsonSync(metadataPath);
|
|
8318
8309
|
}
|
|
8319
8310
|
function buildWorker2() {
|
|
8320
8311
|
console.log(import_chalk22.default.blue("Building worker..."));
|
|
@@ -8331,23 +8322,23 @@ function buildWorker2() {
|
|
|
8331
8322
|
}
|
|
8332
8323
|
}
|
|
8333
8324
|
function getBuiltWorker2() {
|
|
8334
|
-
const distWorkerDir =
|
|
8335
|
-
if (!
|
|
8325
|
+
const distWorkerDir = import_path14.default.join(PROJECT_DIR4, "dist-worker");
|
|
8326
|
+
if (!import_fs_extra9.default.existsSync(distWorkerDir)) {
|
|
8336
8327
|
throw createConfigError("Built worker output not found: `dist-worker/`.", [
|
|
8337
8328
|
"Make sure `npm run build:worker` completed successfully."
|
|
8338
8329
|
]);
|
|
8339
8330
|
}
|
|
8340
|
-
const workerJsPath =
|
|
8341
|
-
if (!
|
|
8331
|
+
const workerJsPath = import_path14.default.join(distWorkerDir, "worker.js");
|
|
8332
|
+
if (!import_fs_extra9.default.existsSync(workerJsPath)) {
|
|
8342
8333
|
throw createConfigError("Built worker entry file not found: `dist-worker/worker.js`.", [
|
|
8343
8334
|
"Check the worker build output and bundler config."
|
|
8344
8335
|
]);
|
|
8345
8336
|
}
|
|
8346
8337
|
const modulePaths = [];
|
|
8347
|
-
const files =
|
|
8338
|
+
const files = import_fs_extra9.default.readdirSync(distWorkerDir);
|
|
8348
8339
|
for (const file of files) {
|
|
8349
8340
|
if (file.endsWith(".js") && file !== "worker.js") {
|
|
8350
|
-
modulePaths.push(
|
|
8341
|
+
modulePaths.push(import_path14.default.join(distWorkerDir, file));
|
|
8351
8342
|
}
|
|
8352
8343
|
}
|
|
8353
8344
|
return { workerJsPath, modulePaths };
|
|
@@ -8368,13 +8359,13 @@ async function updateWorker(workerJsPath, modulePaths, metadata, projectName) {
|
|
|
8368
8359
|
formData.append("metadata", new Blob2([JSON.stringify(metadata)], {
|
|
8369
8360
|
type: "application/json"
|
|
8370
8361
|
}), "metadata.json");
|
|
8371
|
-
const workerCode =
|
|
8362
|
+
const workerCode = import_fs_extra9.default.readFileSync(workerJsPath, "utf-8");
|
|
8372
8363
|
formData.append("worker.js", new Blob2([workerCode], {
|
|
8373
8364
|
type: "application/javascript+module"
|
|
8374
8365
|
}), "worker.js");
|
|
8375
8366
|
for (const modulePath of modulePaths) {
|
|
8376
|
-
const filename =
|
|
8377
|
-
const content =
|
|
8367
|
+
const filename = import_path14.default.basename(modulePath);
|
|
8368
|
+
const content = import_fs_extra9.default.readFileSync(modulePath, "utf-8");
|
|
8378
8369
|
formData.append(filename, new Blob2([content], {
|
|
8379
8370
|
type: "application/javascript+module"
|
|
8380
8371
|
}), filename);
|
|
@@ -8436,11 +8427,11 @@ async function updateWorkerCmd(options) {
|
|
|
8436
8427
|
"Run `pinme login` and retry."
|
|
8437
8428
|
]);
|
|
8438
8429
|
}
|
|
8439
|
-
const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ?
|
|
8440
|
-
const tokenFileSrc =
|
|
8441
|
-
const tokenFileDst =
|
|
8442
|
-
if (
|
|
8443
|
-
|
|
8430
|
+
const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path14.default.join(PROJECT_DIR4, options.projectName || options.name) : PROJECT_DIR4;
|
|
8431
|
+
const tokenFileSrc = import_path14.default.join(PROJECT_DIR4, ".token.json");
|
|
8432
|
+
const tokenFileDst = import_path14.default.join(projectDir, ".token.json");
|
|
8433
|
+
if (import_fs_extra9.default.existsSync(tokenFileSrc) && !import_fs_extra9.default.existsSync(tokenFileDst)) {
|
|
8434
|
+
import_fs_extra9.default.copySync(tokenFileSrc, tokenFileDst);
|
|
8444
8435
|
}
|
|
8445
8436
|
console.log(import_chalk22.default.blue("Updating worker...\n"));
|
|
8446
8437
|
console.log(import_chalk22.default.gray(`Project dir: ${PROJECT_DIR4}`));
|
|
@@ -8470,18 +8461,18 @@ async function updateWorkerCmd(options) {
|
|
|
8470
8461
|
|
|
8471
8462
|
// bin/updateWeb.ts
|
|
8472
8463
|
var import_chalk23 = __toESM(require("chalk"));
|
|
8473
|
-
var
|
|
8474
|
-
var
|
|
8464
|
+
var import_fs_extra10 = __toESM(require("fs-extra"));
|
|
8465
|
+
var import_path15 = __toESM(require("path"));
|
|
8475
8466
|
var import_child_process6 = require("child_process");
|
|
8476
8467
|
var PROJECT_DIR5 = process.cwd();
|
|
8477
8468
|
function loadConfig4() {
|
|
8478
|
-
const configPath =
|
|
8479
|
-
if (!
|
|
8469
|
+
const configPath = import_path15.default.join(PROJECT_DIR5, "pinme.toml");
|
|
8470
|
+
if (!import_fs_extra10.default.existsSync(configPath)) {
|
|
8480
8471
|
throw createConfigError("`pinme.toml` not found in the current directory.", [
|
|
8481
8472
|
"Run this command from the Pinme project root."
|
|
8482
8473
|
]);
|
|
8483
8474
|
}
|
|
8484
|
-
const configContent =
|
|
8475
|
+
const configContent = import_fs_extra10.default.readFileSync(configPath, "utf-8");
|
|
8485
8476
|
const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
|
|
8486
8477
|
return {
|
|
8487
8478
|
project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
|
|
@@ -8504,8 +8495,10 @@ function buildFrontend2() {
|
|
|
8504
8495
|
async function deployFrontend2(projectName) {
|
|
8505
8496
|
console.log(import_chalk23.default.blue("Deploying frontend to IPFS..."));
|
|
8506
8497
|
try {
|
|
8507
|
-
const
|
|
8508
|
-
|
|
8498
|
+
const headers = getAuthHeaders();
|
|
8499
|
+
const uploadResult = await uploadPath(import_path15.default.join(PROJECT_DIR5, "frontend", "dist"), {
|
|
8500
|
+
projectName,
|
|
8501
|
+
uid: headers["token-address"]
|
|
8509
8502
|
});
|
|
8510
8503
|
console.log(import_chalk23.default.green(`Frontend deployed to IPFS: ${uploadResult.publicUrl}`));
|
|
8511
8504
|
} catch (error) {
|
|
@@ -8522,11 +8515,11 @@ async function updateWebCmd(options) {
|
|
|
8522
8515
|
"Run `pinme login` and retry."
|
|
8523
8516
|
]);
|
|
8524
8517
|
}
|
|
8525
|
-
const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ?
|
|
8526
|
-
const tokenFileSrc =
|
|
8527
|
-
const tokenFileDst =
|
|
8528
|
-
if (
|
|
8529
|
-
|
|
8518
|
+
const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path15.default.join(PROJECT_DIR5, options.projectName || options.name) : PROJECT_DIR5;
|
|
8519
|
+
const tokenFileSrc = import_path15.default.join(PROJECT_DIR5, ".token.json");
|
|
8520
|
+
const tokenFileDst = import_path15.default.join(projectDir, ".token.json");
|
|
8521
|
+
if (import_fs_extra10.default.existsSync(tokenFileSrc) && !import_fs_extra10.default.existsSync(tokenFileDst)) {
|
|
8522
|
+
import_fs_extra10.default.copySync(tokenFileSrc, tokenFileDst);
|
|
8530
8523
|
}
|
|
8531
8524
|
console.log(import_chalk23.default.blue("Updating web (frontend)...\n"));
|
|
8532
8525
|
console.log(import_chalk23.default.gray(`Project dir: ${PROJECT_DIR5}`));
|
|
@@ -8552,14 +8545,14 @@ async function updateWebCmd(options) {
|
|
|
8552
8545
|
// bin/delete.ts
|
|
8553
8546
|
var import_chalk24 = __toESM(require("chalk"));
|
|
8554
8547
|
var import_inquirer9 = __toESM(require("inquirer"));
|
|
8555
|
-
var
|
|
8556
|
-
var
|
|
8548
|
+
var import_fs_extra11 = __toESM(require("fs-extra"));
|
|
8549
|
+
var import_path16 = __toESM(require("path"));
|
|
8557
8550
|
function getProjectName() {
|
|
8558
|
-
const configPath =
|
|
8559
|
-
if (!
|
|
8551
|
+
const configPath = import_path16.default.join(process.cwd(), "pinme.toml");
|
|
8552
|
+
if (!import_fs_extra11.default.existsSync(configPath)) {
|
|
8560
8553
|
return null;
|
|
8561
8554
|
}
|
|
8562
|
-
const config =
|
|
8555
|
+
const config = import_fs_extra11.default.readFileSync(configPath, "utf-8");
|
|
8563
8556
|
const match = config.match(/project_name\s*=\s*"([^"]+)"/);
|
|
8564
8557
|
return (match == null ? void 0 : match[1]) || null;
|
|
8565
8558
|
}
|