pinme 2.0.0-beta.5 → 2.0.0-beta.6
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 +49 -146
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -96,8 +96,8 @@ 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
|
|
99
|
+
var fs16 = require("fs");
|
|
100
|
+
var path17 = require("path");
|
|
101
101
|
var os5 = require("os");
|
|
102
102
|
var crypto3 = require("crypto");
|
|
103
103
|
var packageJson = require_package();
|
|
@@ -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
|
}
|
|
@@ -1519,11 +1519,11 @@ function checkNodeVersion() {
|
|
|
1519
1519
|
|
|
1520
1520
|
// bin/index.ts
|
|
1521
1521
|
var import_commander = require("commander");
|
|
1522
|
-
var
|
|
1522
|
+
var import_chalk22 = __toESM(require("chalk"));
|
|
1523
1523
|
var import_figlet5 = __toESM(require("figlet"));
|
|
1524
1524
|
|
|
1525
1525
|
// package.json
|
|
1526
|
-
var version = "2.0.0-beta.
|
|
1526
|
+
var version = "2.0.0-beta.6";
|
|
1527
1527
|
|
|
1528
1528
|
// bin/upload.ts
|
|
1529
1529
|
var import_path7 = __toESM(require("path"));
|
|
@@ -1968,9 +1968,9 @@ function isVisitable(thing) {
|
|
|
1968
1968
|
function removeBrackets(key) {
|
|
1969
1969
|
return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
|
|
1970
1970
|
}
|
|
1971
|
-
function renderKey(
|
|
1972
|
-
if (!
|
|
1973
|
-
return
|
|
1971
|
+
function renderKey(path17, key, dots) {
|
|
1972
|
+
if (!path17) return key;
|
|
1973
|
+
return path17.concat(key).map(function each(token, i) {
|
|
1974
1974
|
token = removeBrackets(token);
|
|
1975
1975
|
return !dots && i ? "[" + token + "]" : token;
|
|
1976
1976
|
}).join(dots ? "." : "");
|
|
@@ -2015,9 +2015,9 @@ function toFormData(obj, formData, options) {
|
|
|
2015
2015
|
}
|
|
2016
2016
|
return value;
|
|
2017
2017
|
}
|
|
2018
|
-
function defaultVisitor(value, key,
|
|
2018
|
+
function defaultVisitor(value, key, path17) {
|
|
2019
2019
|
let arr = value;
|
|
2020
|
-
if (value && !
|
|
2020
|
+
if (value && !path17 && typeof value === "object") {
|
|
2021
2021
|
if (utils_default.endsWith(key, "{}")) {
|
|
2022
2022
|
key = metaTokens ? key : key.slice(0, -2);
|
|
2023
2023
|
value = JSON.stringify(value);
|
|
@@ -2036,7 +2036,7 @@ function toFormData(obj, formData, options) {
|
|
|
2036
2036
|
if (isVisitable(value)) {
|
|
2037
2037
|
return true;
|
|
2038
2038
|
}
|
|
2039
|
-
formData.append(renderKey(
|
|
2039
|
+
formData.append(renderKey(path17, key, dots), convertValue(value));
|
|
2040
2040
|
return false;
|
|
2041
2041
|
}
|
|
2042
2042
|
const stack = [];
|
|
@@ -2045,10 +2045,10 @@ function toFormData(obj, formData, options) {
|
|
|
2045
2045
|
convertValue,
|
|
2046
2046
|
isVisitable
|
|
2047
2047
|
});
|
|
2048
|
-
function build(value,
|
|
2048
|
+
function build(value, path17) {
|
|
2049
2049
|
if (utils_default.isUndefined(value)) return;
|
|
2050
2050
|
if (stack.indexOf(value) !== -1) {
|
|
2051
|
-
throw Error("Circular reference detected in " +
|
|
2051
|
+
throw Error("Circular reference detected in " + path17.join("."));
|
|
2052
2052
|
}
|
|
2053
2053
|
stack.push(value);
|
|
2054
2054
|
utils_default.forEach(value, function each(el, key) {
|
|
@@ -2056,11 +2056,11 @@ function toFormData(obj, formData, options) {
|
|
|
2056
2056
|
formData,
|
|
2057
2057
|
el,
|
|
2058
2058
|
utils_default.isString(key) ? key.trim() : key,
|
|
2059
|
-
|
|
2059
|
+
path17,
|
|
2060
2060
|
exposedHelpers
|
|
2061
2061
|
);
|
|
2062
2062
|
if (result === true) {
|
|
2063
|
-
build(el,
|
|
2063
|
+
build(el, path17 ? path17.concat(key) : [key]);
|
|
2064
2064
|
}
|
|
2065
2065
|
});
|
|
2066
2066
|
stack.pop();
|
|
@@ -2221,7 +2221,7 @@ var node_default = {
|
|
|
2221
2221
|
// node_modules/.pnpm/axios@1.3.2/node_modules/axios/lib/helpers/toURLEncodedForm.js
|
|
2222
2222
|
function toURLEncodedForm(data, options) {
|
|
2223
2223
|
return toFormData_default(data, new node_default.classes.URLSearchParams(), Object.assign({
|
|
2224
|
-
visitor: function(value, key,
|
|
2224
|
+
visitor: function(value, key, path17, helpers) {
|
|
2225
2225
|
if (node_default.isNode && utils_default.isBuffer(value)) {
|
|
2226
2226
|
this.append(key, value.toString("base64"));
|
|
2227
2227
|
return false;
|
|
@@ -2250,10 +2250,10 @@ function arrayToObject(arr) {
|
|
|
2250
2250
|
return obj;
|
|
2251
2251
|
}
|
|
2252
2252
|
function formDataToJSON(formData) {
|
|
2253
|
-
function buildPath(
|
|
2254
|
-
let name =
|
|
2253
|
+
function buildPath(path17, value, target, index) {
|
|
2254
|
+
let name = path17[index++];
|
|
2255
2255
|
const isNumericKey = Number.isFinite(+name);
|
|
2256
|
-
const isLast = index >=
|
|
2256
|
+
const isLast = index >= path17.length;
|
|
2257
2257
|
name = !name && utils_default.isArray(target) ? target.length : name;
|
|
2258
2258
|
if (isLast) {
|
|
2259
2259
|
if (utils_default.hasOwnProp(target, name)) {
|
|
@@ -2266,7 +2266,7 @@ function formDataToJSON(formData) {
|
|
|
2266
2266
|
if (!target[name] || !utils_default.isObject(target[name])) {
|
|
2267
2267
|
target[name] = [];
|
|
2268
2268
|
}
|
|
2269
|
-
const result = buildPath(
|
|
2269
|
+
const result = buildPath(path17, value, target[name], index);
|
|
2270
2270
|
if (result && utils_default.isArray(target[name])) {
|
|
2271
2271
|
target[name] = arrayToObject(target[name]);
|
|
2272
2272
|
}
|
|
@@ -3328,9 +3328,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3328
3328
|
auth = urlUsername + ":" + urlPassword;
|
|
3329
3329
|
}
|
|
3330
3330
|
auth && headers.delete("authorization");
|
|
3331
|
-
let
|
|
3331
|
+
let path17;
|
|
3332
3332
|
try {
|
|
3333
|
-
|
|
3333
|
+
path17 = buildURL(
|
|
3334
3334
|
parsed.pathname + parsed.search,
|
|
3335
3335
|
config.params,
|
|
3336
3336
|
config.paramsSerializer
|
|
@@ -3348,7 +3348,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
3348
3348
|
false
|
|
3349
3349
|
);
|
|
3350
3350
|
const options = {
|
|
3351
|
-
path:
|
|
3351
|
+
path: path17,
|
|
3352
3352
|
method,
|
|
3353
3353
|
headers: headers.toJSON(),
|
|
3354
3354
|
agents: { http: config.httpAgent, https: config.httpsAgent },
|
|
@@ -3567,14 +3567,14 @@ var cookies_default = node_default.isStandardBrowserEnv ? (
|
|
|
3567
3567
|
// Standard browser envs support document.cookie
|
|
3568
3568
|
/* @__PURE__ */ function standardBrowserEnv() {
|
|
3569
3569
|
return {
|
|
3570
|
-
write: function write(name, value, expires,
|
|
3570
|
+
write: function write(name, value, expires, path17, domain, secure) {
|
|
3571
3571
|
const cookie = [];
|
|
3572
3572
|
cookie.push(name + "=" + encodeURIComponent(value));
|
|
3573
3573
|
if (utils_default.isNumber(expires)) {
|
|
3574
3574
|
cookie.push("expires=" + new Date(expires).toGMTString());
|
|
3575
3575
|
}
|
|
3576
|
-
if (utils_default.isString(
|
|
3577
|
-
cookie.push("path=" +
|
|
3576
|
+
if (utils_default.isString(path17)) {
|
|
3577
|
+
cookie.push("path=" + path17);
|
|
3578
3578
|
}
|
|
3579
3579
|
if (utils_default.isString(domain)) {
|
|
3580
3580
|
cookie.push("domain=" + domain);
|
|
@@ -7110,7 +7110,6 @@ var import_fs_extra6 = __toESM(require("fs-extra"));
|
|
|
7110
7110
|
var import_path11 = __toESM(require("path"));
|
|
7111
7111
|
var import_inquirer8 = __toESM(require("inquirer"));
|
|
7112
7112
|
var import_child_process2 = require("child_process");
|
|
7113
|
-
var TEMPLATE_DIR = import_path11.default.join(__dirname, "../template");
|
|
7114
7113
|
var PROJECT_DIR = process.cwd();
|
|
7115
7114
|
var API_BASE = "https://pinme.dev/api/v4";
|
|
7116
7115
|
var TEMPLATE_REPO = "https://github.com/glitternetwork/pinme-worker-template.git";
|
|
@@ -7246,6 +7245,16 @@ Directory "${projectName}" already exists.`));
|
|
|
7246
7245
|
);
|
|
7247
7246
|
console.log(import_chalk16.default.green(` Saved metadata.json`));
|
|
7248
7247
|
}
|
|
7248
|
+
const wranglerPath = import_path11.default.join(backendDir, "wrangler.toml");
|
|
7249
|
+
if (import_fs_extra6.default.existsSync(wranglerPath) && workerData.api_key) {
|
|
7250
|
+
let wranglerContent = import_fs_extra6.default.readFileSync(wranglerPath, "utf-8");
|
|
7251
|
+
wranglerContent = wranglerContent.replace(
|
|
7252
|
+
/^API_KEY = ".*"$/m,
|
|
7253
|
+
`API_KEY = "${workerData.api_key}"`
|
|
7254
|
+
);
|
|
7255
|
+
import_fs_extra6.default.writeFileSync(wranglerPath, wranglerContent);
|
|
7256
|
+
console.log(import_chalk16.default.green(` Updated backend/wrangler.toml API_KEY`));
|
|
7257
|
+
}
|
|
7249
7258
|
const envExamplePath = import_path11.default.join(targetDir, "frontend", ".env.example");
|
|
7250
7259
|
const envPath = import_path11.default.join(targetDir, "frontend", ".env");
|
|
7251
7260
|
if (import_fs_extra6.default.existsSync(envExamplePath)) {
|
|
@@ -7259,6 +7268,10 @@ Directory "${projectName}" already exists.`));
|
|
|
7259
7268
|
/^VITE_API_URL=.*$/m,
|
|
7260
7269
|
`VITE_API_URL=${workerData.api_domain}`
|
|
7261
7270
|
);
|
|
7271
|
+
envContent = envContent.replace(
|
|
7272
|
+
/^VITE_API_URL=.*$/m,
|
|
7273
|
+
`VITE_API_KEY=${workerData.api_key}`
|
|
7274
|
+
);
|
|
7262
7275
|
import_fs_extra6.default.writeFileSync(envPath, envContent);
|
|
7263
7276
|
console.log(import_chalk16.default.green(` Created frontend/.env file`));
|
|
7264
7277
|
}
|
|
@@ -8002,123 +8015,14 @@ Project: ${data.data.project_name}`));
|
|
|
8002
8015
|
}
|
|
8003
8016
|
}
|
|
8004
8017
|
|
|
8005
|
-
// bin/sendEmail.ts
|
|
8006
|
-
var import_chalk22 = __toESM(require("chalk"));
|
|
8007
|
-
var import_inquirer10 = __toESM(require("inquirer"));
|
|
8008
|
-
var import_fs_extra12 = __toESM(require("fs-extra"));
|
|
8009
|
-
var import_path17 = __toESM(require("path"));
|
|
8010
|
-
var PROJECT_DIR6 = process.cwd();
|
|
8011
|
-
var API_BASE6 = "https://pinme.dev/api/v4";
|
|
8012
|
-
async function sendEmailCmd(options) {
|
|
8013
|
-
var _a, _b;
|
|
8014
|
-
try {
|
|
8015
|
-
console.log(import_chalk22.default.blue("Sending email...\n"));
|
|
8016
|
-
let apiKey = options.apiKey;
|
|
8017
|
-
if (!apiKey) {
|
|
8018
|
-
const configPath = import_path17.default.join(PROJECT_DIR6, "pinme.toml");
|
|
8019
|
-
if (import_fs_extra12.default.existsSync(configPath)) {
|
|
8020
|
-
const config = import_fs_extra12.default.readFileSync(configPath, "utf-8");
|
|
8021
|
-
const apiKeyMatch = config.match(/api_key\s*=\s*"([^"]+)"/);
|
|
8022
|
-
if (apiKeyMatch) {
|
|
8023
|
-
apiKey = apiKeyMatch[1];
|
|
8024
|
-
}
|
|
8025
|
-
}
|
|
8026
|
-
}
|
|
8027
|
-
let to = options.to;
|
|
8028
|
-
let subject = options.subject;
|
|
8029
|
-
let html = options.html;
|
|
8030
|
-
if (!to || !subject || !html) {
|
|
8031
|
-
const answers = await import_inquirer10.default.prompt([
|
|
8032
|
-
{
|
|
8033
|
-
type: "input",
|
|
8034
|
-
name: "to",
|
|
8035
|
-
message: "To (email address):",
|
|
8036
|
-
validate: (input) => {
|
|
8037
|
-
if (!input.trim()) return "Email address is required";
|
|
8038
|
-
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(input)) {
|
|
8039
|
-
return "Please enter a valid email address";
|
|
8040
|
-
}
|
|
8041
|
-
return true;
|
|
8042
|
-
}
|
|
8043
|
-
},
|
|
8044
|
-
{
|
|
8045
|
-
type: "input",
|
|
8046
|
-
name: "subject",
|
|
8047
|
-
message: "Subject:",
|
|
8048
|
-
validate: (input) => {
|
|
8049
|
-
if (!input.trim()) return "Subject is required";
|
|
8050
|
-
return true;
|
|
8051
|
-
}
|
|
8052
|
-
},
|
|
8053
|
-
{
|
|
8054
|
-
type: "editor",
|
|
8055
|
-
name: "html",
|
|
8056
|
-
message: "HTML content (will open in editor):",
|
|
8057
|
-
default: "<p>Hello!</p>",
|
|
8058
|
-
validate: (input) => {
|
|
8059
|
-
if (!input.trim()) return "HTML content is required";
|
|
8060
|
-
return true;
|
|
8061
|
-
}
|
|
8062
|
-
}
|
|
8063
|
-
]);
|
|
8064
|
-
to = answers.to;
|
|
8065
|
-
subject = answers.subject;
|
|
8066
|
-
html = answers.html;
|
|
8067
|
-
}
|
|
8068
|
-
if (!apiKey) {
|
|
8069
|
-
const keyAnswer = await import_inquirer10.default.prompt([
|
|
8070
|
-
{
|
|
8071
|
-
type: "input",
|
|
8072
|
-
name: "apiKey",
|
|
8073
|
-
message: "API Key (from project config or create_worker response):",
|
|
8074
|
-
validate: (input) => {
|
|
8075
|
-
if (!input.trim()) return "API Key is required";
|
|
8076
|
-
return true;
|
|
8077
|
-
}
|
|
8078
|
-
}
|
|
8079
|
-
]);
|
|
8080
|
-
apiKey = keyAnswer.apiKey;
|
|
8081
|
-
}
|
|
8082
|
-
console.log(import_chalk22.default.blue("Sending email..."));
|
|
8083
|
-
const apiUrl = `${API_BASE6}/send_email`;
|
|
8084
|
-
console.log(import_chalk22.default.gray(`API URL: ${apiUrl}`));
|
|
8085
|
-
const response = await axios_default.post(apiUrl, {
|
|
8086
|
-
to,
|
|
8087
|
-
subject,
|
|
8088
|
-
html
|
|
8089
|
-
}, {
|
|
8090
|
-
headers: {
|
|
8091
|
-
"X-API-Key": apiKey,
|
|
8092
|
-
"Content-Type": "application/json"
|
|
8093
|
-
}
|
|
8094
|
-
});
|
|
8095
|
-
const data = response.data;
|
|
8096
|
-
if (data.code === 200) {
|
|
8097
|
-
console.log(import_chalk22.default.green("\n\u2705 Email sent successfully!"));
|
|
8098
|
-
console.log(import_chalk22.default.gray(`
|
|
8099
|
-
To: ${to}`));
|
|
8100
|
-
console.log(import_chalk22.default.gray(`Subject: ${subject}`));
|
|
8101
|
-
} else {
|
|
8102
|
-
const errorMsg = (data == null ? void 0 : data.msg) || "Failed to send email";
|
|
8103
|
-
throw new Error(errorMsg);
|
|
8104
|
-
}
|
|
8105
|
-
process.exit(0);
|
|
8106
|
-
} catch (error) {
|
|
8107
|
-
const errorMsg = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.msg) || error.message || "Failed to send email";
|
|
8108
|
-
console.error(import_chalk22.default.red(`
|
|
8109
|
-
\u274C Error: ${errorMsg}`));
|
|
8110
|
-
process.exit(1);
|
|
8111
|
-
}
|
|
8112
|
-
}
|
|
8113
|
-
|
|
8114
8018
|
// bin/index.ts
|
|
8115
8019
|
import_dotenv.default.config();
|
|
8116
8020
|
checkNodeVersion();
|
|
8117
8021
|
function showBanner() {
|
|
8118
8022
|
console.log(
|
|
8119
|
-
|
|
8023
|
+
import_chalk22.default.cyan(import_figlet5.default.textSync("Pinme", { horizontalLayout: "full" }))
|
|
8120
8024
|
);
|
|
8121
|
-
console.log(
|
|
8025
|
+
console.log(import_chalk22.default.cyan("A command-line tool for uploading files to IPFS\n"));
|
|
8122
8026
|
}
|
|
8123
8027
|
var program = new import_commander.Command();
|
|
8124
8028
|
program.name("pinme").version(version).option("-v, --version", "output the current version");
|
|
@@ -8142,7 +8046,6 @@ program.command("update-db").description("Execute database migration").action(()
|
|
|
8142
8046
|
program.command("update-worker").description("Execute worker migration").action(() => updateWorkerCmd());
|
|
8143
8047
|
program.command("update-web").description("Deploy frontend to IPFS").action((options) => updateWebCmd(options));
|
|
8144
8048
|
program.command("delete").description("Delete a project (Worker, domain, D1 database)").argument("[name]", "Project name").option("-f, --force", "Skip confirmation").action((name, options) => deleteCmd({ name, force: options == null ? void 0 : options.force }));
|
|
8145
|
-
program.command("send-email").description("Send email via PinMe API").option("-t, --to <email>", "Recipient email address").option("-s, --subject <subject>", "Email subject").option("-h, --html <content>", "HTML content").option("--text <content>", "Plain text content (alternative to --html)").option("-k, --api-key <key>", "API Key (or from pinme.toml)").action((options) => sendEmailCmd(options));
|
|
8146
8049
|
program.command("domain").description("Alias for 'my-domains' command").action(() => myDomainsCmd());
|
|
8147
8050
|
program.command("list").description("show upload history").option(
|
|
8148
8051
|
"-l, --limit <number>",
|