pinme 2.0.5 → 2.0.6-beta.1
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 +62 -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.1";
|
|
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,52 @@ 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 resolveUploadProjectName(targetPath) {
|
|
7426
|
+
if (APP_CONFIG.pinmeProjectName) {
|
|
7427
|
+
return APP_CONFIG.pinmeProjectName;
|
|
7428
|
+
}
|
|
7429
|
+
const configPaths = [
|
|
7430
|
+
findPinmeConfig(targetPath),
|
|
7431
|
+
findPinmeConfig(process.cwd())
|
|
7432
|
+
].filter(
|
|
7433
|
+
(value, index, values) => Boolean(value) && values.indexOf(value) === index
|
|
7434
|
+
);
|
|
7435
|
+
for (const configPath of configPaths) {
|
|
7436
|
+
const projectName = readProjectNameFromConfig(configPath);
|
|
7437
|
+
if (projectName) {
|
|
7438
|
+
return projectName;
|
|
7439
|
+
}
|
|
7440
|
+
}
|
|
7441
|
+
return void 0;
|
|
7442
|
+
}
|
|
7398
7443
|
function getDomainFromArgs() {
|
|
7399
7444
|
const args = process.argv.slice(2);
|
|
7400
7445
|
const dIdx = args.findIndex((a) => a === "--domain" || a === "-d");
|
|
@@ -7518,6 +7563,10 @@ var upload_default = async (options) => {
|
|
|
7518
7563
|
return;
|
|
7519
7564
|
}
|
|
7520
7565
|
const pathKind = getPathKind(absolutePath);
|
|
7566
|
+
const projectName = resolveUploadProjectName(absolutePath);
|
|
7567
|
+
if (projectName) {
|
|
7568
|
+
console.log(import_chalk7.default.gray(`Project: ${projectName}`));
|
|
7569
|
+
}
|
|
7521
7570
|
const isDns = dnsArg || (domainArg ? isDnsDomain(domainArg) : false);
|
|
7522
7571
|
const displayDomain = domainArg == null ? void 0 : domainArg.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
7523
7572
|
if (isDns && domainArg) {
|
|
@@ -7569,7 +7618,7 @@ var upload_default = async (options) => {
|
|
|
7569
7618
|
let result;
|
|
7570
7619
|
try {
|
|
7571
7620
|
result = await uploadPath(absolutePath, {
|
|
7572
|
-
projectName
|
|
7621
|
+
projectName,
|
|
7573
7622
|
uid: authConfig == null ? void 0 : authConfig.address
|
|
7574
7623
|
});
|
|
7575
7624
|
} catch (error) {
|
|
@@ -7596,12 +7645,12 @@ var upload_default = async (options) => {
|
|
|
7596
7645
|
a: resolveTrackAction2(TRACK_EVENTS.uploadSuccess),
|
|
7597
7646
|
path_kind: pathKind,
|
|
7598
7647
|
has_domain: Boolean(domainArg),
|
|
7599
|
-
project_name:
|
|
7648
|
+
project_name: projectName
|
|
7600
7649
|
});
|
|
7601
7650
|
console.log(
|
|
7602
7651
|
import_chalk7.default.cyan(import_figlet.default.textSync("Successful", { horizontalLayout: "full" }))
|
|
7603
7652
|
);
|
|
7604
|
-
await printUploadUrls(result);
|
|
7653
|
+
await printUploadUrls(result, projectName);
|
|
7605
7654
|
if (domainArg) {
|
|
7606
7655
|
console.log(
|
|
7607
7656
|
import_chalk7.default.blue(
|
|
@@ -7634,6 +7683,10 @@ var upload_default = async (options) => {
|
|
|
7634
7683
|
return;
|
|
7635
7684
|
}
|
|
7636
7685
|
const pathKind = getPathKind(absolutePath);
|
|
7686
|
+
const projectName = resolveUploadProjectName(absolutePath);
|
|
7687
|
+
if (projectName) {
|
|
7688
|
+
console.log(import_chalk7.default.gray(`Project: ${projectName}`));
|
|
7689
|
+
}
|
|
7637
7690
|
const isDns = dnsArg || (domainArg ? isDnsDomain(domainArg) : false);
|
|
7638
7691
|
const displayDomain = domainArg == null ? void 0 : domainArg.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
7639
7692
|
if (isDns && domainArg) {
|
|
@@ -7685,7 +7738,7 @@ var upload_default = async (options) => {
|
|
|
7685
7738
|
let result;
|
|
7686
7739
|
try {
|
|
7687
7740
|
result = await uploadPath(absolutePath, {
|
|
7688
|
-
projectName
|
|
7741
|
+
projectName,
|
|
7689
7742
|
uid: authConfig == null ? void 0 : authConfig.address
|
|
7690
7743
|
});
|
|
7691
7744
|
} catch (error) {
|
|
@@ -7712,12 +7765,12 @@ var upload_default = async (options) => {
|
|
|
7712
7765
|
a: resolveTrackAction2(TRACK_EVENTS.uploadSuccess),
|
|
7713
7766
|
path_kind: pathKind,
|
|
7714
7767
|
has_domain: Boolean(domainArg),
|
|
7715
|
-
project_name:
|
|
7768
|
+
project_name: projectName
|
|
7716
7769
|
});
|
|
7717
7770
|
console.log(
|
|
7718
7771
|
import_chalk7.default.cyan(import_figlet.default.textSync("Successful", { horizontalLayout: "full" }))
|
|
7719
7772
|
);
|
|
7720
|
-
await printUploadUrls(result);
|
|
7773
|
+
await printUploadUrls(result, projectName);
|
|
7721
7774
|
if (domainArg) {
|
|
7722
7775
|
console.log(
|
|
7723
7776
|
import_chalk7.default.blue(
|