pinme 2.0.5 → 2.0.6-beta.2
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 +72 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5978,7 +5978,7 @@ var import_chalk26 = __toESM(require("chalk"));
|
|
|
5978
5978
|
var import_figlet5 = __toESM(require("figlet"));
|
|
5979
5979
|
|
|
5980
5980
|
// package.json
|
|
5981
|
-
var version = "2.0.
|
|
5981
|
+
var version = "2.0.6-beta.2";
|
|
5982
5982
|
|
|
5983
5983
|
// bin/upload.ts
|
|
5984
5984
|
var import_path7 = __toESM(require("path"));
|
|
@@ -7381,8 +7381,7 @@ function checkPathSync(inputPath) {
|
|
|
7381
7381
|
return null;
|
|
7382
7382
|
}
|
|
7383
7383
|
}
|
|
7384
|
-
async function printUploadUrls(result) {
|
|
7385
|
-
const projectName = APP_CONFIG.pinmeProjectName;
|
|
7384
|
+
async function printUploadUrls(result, projectName) {
|
|
7386
7385
|
const { publicUrl, managementUrl } = await resolveUploadUrls(
|
|
7387
7386
|
result.contentHash,
|
|
7388
7387
|
{
|
|
@@ -7395,6 +7394,62 @@ async function printUploadUrls(result) {
|
|
|
7395
7394
|
printHighlightedUrl("URL", publicUrl, "primary");
|
|
7396
7395
|
printHighlightedUrl("Management URL", managementUrl, "management");
|
|
7397
7396
|
}
|
|
7397
|
+
function readProjectNameFromConfig(configPath) {
|
|
7398
|
+
var _a2;
|
|
7399
|
+
try {
|
|
7400
|
+
const config = import_fs3.default.readFileSync(configPath, "utf-8");
|
|
7401
|
+
const match = config.match(/project_name\s*=\s*"([^"]+)"/);
|
|
7402
|
+
return ((_a2 = match == null ? void 0 : match[1]) == null ? void 0 : _a2.trim()) || void 0;
|
|
7403
|
+
} catch {
|
|
7404
|
+
return void 0;
|
|
7405
|
+
}
|
|
7406
|
+
}
|
|
7407
|
+
function findPinmeConfig(startPath) {
|
|
7408
|
+
try {
|
|
7409
|
+
let current = import_fs3.default.statSync(startPath).isDirectory() ? startPath : import_path7.default.dirname(startPath);
|
|
7410
|
+
while (true) {
|
|
7411
|
+
const configPath = import_path7.default.join(current, "pinme.toml");
|
|
7412
|
+
if (import_fs3.default.existsSync(configPath)) {
|
|
7413
|
+
return configPath;
|
|
7414
|
+
}
|
|
7415
|
+
const parent = import_path7.default.dirname(current);
|
|
7416
|
+
if (parent === current) {
|
|
7417
|
+
return void 0;
|
|
7418
|
+
}
|
|
7419
|
+
current = parent;
|
|
7420
|
+
}
|
|
7421
|
+
} catch {
|
|
7422
|
+
return void 0;
|
|
7423
|
+
}
|
|
7424
|
+
}
|
|
7425
|
+
function shouldInferProjectNameFromUploadPath(targetPath) {
|
|
7426
|
+
try {
|
|
7427
|
+
return import_fs3.default.statSync(targetPath).isDirectory() && import_path7.default.basename(targetPath) === "dist";
|
|
7428
|
+
} catch {
|
|
7429
|
+
return false;
|
|
7430
|
+
}
|
|
7431
|
+
}
|
|
7432
|
+
function resolveUploadProjectName(targetPath) {
|
|
7433
|
+
if (APP_CONFIG.pinmeProjectName) {
|
|
7434
|
+
return APP_CONFIG.pinmeProjectName;
|
|
7435
|
+
}
|
|
7436
|
+
if (!shouldInferProjectNameFromUploadPath(targetPath)) {
|
|
7437
|
+
return void 0;
|
|
7438
|
+
}
|
|
7439
|
+
const configPaths = [
|
|
7440
|
+
findPinmeConfig(targetPath),
|
|
7441
|
+
findPinmeConfig(process.cwd())
|
|
7442
|
+
].filter(
|
|
7443
|
+
(value, index, values) => Boolean(value) && values.indexOf(value) === index
|
|
7444
|
+
);
|
|
7445
|
+
for (const configPath of configPaths) {
|
|
7446
|
+
const projectName = readProjectNameFromConfig(configPath);
|
|
7447
|
+
if (projectName) {
|
|
7448
|
+
return projectName;
|
|
7449
|
+
}
|
|
7450
|
+
}
|
|
7451
|
+
return void 0;
|
|
7452
|
+
}
|
|
7398
7453
|
function getDomainFromArgs() {
|
|
7399
7454
|
const args = process.argv.slice(2);
|
|
7400
7455
|
const dIdx = args.findIndex((a) => a === "--domain" || a === "-d");
|
|
@@ -7518,6 +7573,10 @@ var upload_default = async (options) => {
|
|
|
7518
7573
|
return;
|
|
7519
7574
|
}
|
|
7520
7575
|
const pathKind = getPathKind(absolutePath);
|
|
7576
|
+
const projectName = resolveUploadProjectName(absolutePath);
|
|
7577
|
+
if (projectName) {
|
|
7578
|
+
console.log(import_chalk7.default.gray(`Project: ${projectName}`));
|
|
7579
|
+
}
|
|
7521
7580
|
const isDns = dnsArg || (domainArg ? isDnsDomain(domainArg) : false);
|
|
7522
7581
|
const displayDomain = domainArg == null ? void 0 : domainArg.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
7523
7582
|
if (isDns && domainArg) {
|
|
@@ -7569,7 +7628,7 @@ var upload_default = async (options) => {
|
|
|
7569
7628
|
let result;
|
|
7570
7629
|
try {
|
|
7571
7630
|
result = await uploadPath(absolutePath, {
|
|
7572
|
-
projectName
|
|
7631
|
+
projectName,
|
|
7573
7632
|
uid: authConfig == null ? void 0 : authConfig.address
|
|
7574
7633
|
});
|
|
7575
7634
|
} catch (error) {
|
|
@@ -7596,12 +7655,12 @@ var upload_default = async (options) => {
|
|
|
7596
7655
|
a: resolveTrackAction2(TRACK_EVENTS.uploadSuccess),
|
|
7597
7656
|
path_kind: pathKind,
|
|
7598
7657
|
has_domain: Boolean(domainArg),
|
|
7599
|
-
project_name:
|
|
7658
|
+
project_name: projectName
|
|
7600
7659
|
});
|
|
7601
7660
|
console.log(
|
|
7602
7661
|
import_chalk7.default.cyan(import_figlet.default.textSync("Successful", { horizontalLayout: "full" }))
|
|
7603
7662
|
);
|
|
7604
|
-
await printUploadUrls(result);
|
|
7663
|
+
await printUploadUrls(result, projectName);
|
|
7605
7664
|
if (domainArg) {
|
|
7606
7665
|
console.log(
|
|
7607
7666
|
import_chalk7.default.blue(
|
|
@@ -7634,6 +7693,10 @@ var upload_default = async (options) => {
|
|
|
7634
7693
|
return;
|
|
7635
7694
|
}
|
|
7636
7695
|
const pathKind = getPathKind(absolutePath);
|
|
7696
|
+
const projectName = resolveUploadProjectName(absolutePath);
|
|
7697
|
+
if (projectName) {
|
|
7698
|
+
console.log(import_chalk7.default.gray(`Project: ${projectName}`));
|
|
7699
|
+
}
|
|
7637
7700
|
const isDns = dnsArg || (domainArg ? isDnsDomain(domainArg) : false);
|
|
7638
7701
|
const displayDomain = domainArg == null ? void 0 : domainArg.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
7639
7702
|
if (isDns && domainArg) {
|
|
@@ -7685,7 +7748,7 @@ var upload_default = async (options) => {
|
|
|
7685
7748
|
let result;
|
|
7686
7749
|
try {
|
|
7687
7750
|
result = await uploadPath(absolutePath, {
|
|
7688
|
-
projectName
|
|
7751
|
+
projectName,
|
|
7689
7752
|
uid: authConfig == null ? void 0 : authConfig.address
|
|
7690
7753
|
});
|
|
7691
7754
|
} catch (error) {
|
|
@@ -7712,12 +7775,12 @@ var upload_default = async (options) => {
|
|
|
7712
7775
|
a: resolveTrackAction2(TRACK_EVENTS.uploadSuccess),
|
|
7713
7776
|
path_kind: pathKind,
|
|
7714
7777
|
has_domain: Boolean(domainArg),
|
|
7715
|
-
project_name:
|
|
7778
|
+
project_name: projectName
|
|
7716
7779
|
});
|
|
7717
7780
|
console.log(
|
|
7718
7781
|
import_chalk7.default.cyan(import_figlet.default.textSync("Successful", { horizontalLayout: "full" }))
|
|
7719
7782
|
);
|
|
7720
|
-
await printUploadUrls(result);
|
|
7783
|
+
await printUploadUrls(result, projectName);
|
|
7721
7784
|
if (domainArg) {
|
|
7722
7785
|
console.log(
|
|
7723
7786
|
import_chalk7.default.blue(
|