@ubiquity-os/plugin-sdk 3.12.0 → 3.12.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/configuration.js +17 -9
- package/dist/configuration.mjs +17 -9
- package/package.json +1 -1
package/dist/configuration.js
CHANGED
|
@@ -175,6 +175,9 @@ function resolveManifestUrl(pluginUrl) {
|
|
|
175
175
|
while (pathname.endsWith("/") && pathname.length > 1) {
|
|
176
176
|
pathname = pathname.slice(0, -1);
|
|
177
177
|
}
|
|
178
|
+
if (pathname === "/") {
|
|
179
|
+
pathname = EMPTY_STRING;
|
|
180
|
+
}
|
|
178
181
|
if (pathname.endsWith(".json")) {
|
|
179
182
|
parsed.search = EMPTY_STRING;
|
|
180
183
|
parsed.hash = EMPTY_STRING;
|
|
@@ -462,7 +465,7 @@ var ConfigurationHandler = class {
|
|
|
462
465
|
return { config: targetRepoConfiguration, imports, errors, rawData };
|
|
463
466
|
}
|
|
464
467
|
_decodeConfiguration(location, config) {
|
|
465
|
-
this._logger.
|
|
468
|
+
this._logger.debug("Decoding configuration", { owner: location.owner, repository: location.repo });
|
|
466
469
|
try {
|
|
467
470
|
const configSchemaWithDefaults = import_value.Value.Default(configSchema, config);
|
|
468
471
|
const errors = import_value.Value.Errors(configSchema, configSchemaWithDefaults);
|
|
@@ -557,7 +560,7 @@ var ConfigurationHandler = class {
|
|
|
557
560
|
...ref ? { ref } : {},
|
|
558
561
|
mediaType: { format: "raw" }
|
|
559
562
|
});
|
|
560
|
-
|
|
563
|
+
this._logger.debug("Configuration file found", { owner, repository, filePath, rateLimitRemaining: headers?.["x-ratelimit-remaining"] });
|
|
561
564
|
return data;
|
|
562
565
|
} catch (err) {
|
|
563
566
|
this._handleDownloadError(err, { owner, repository, filePath });
|
|
@@ -581,11 +584,11 @@ var ConfigurationHandler = class {
|
|
|
581
584
|
* Parse the raw YAML content and returns the loaded YAML, or errors if any.
|
|
582
585
|
*/
|
|
583
586
|
parseYaml(data) {
|
|
584
|
-
this._logger.
|
|
587
|
+
this._logger.debug("Will attempt to parse YAML data");
|
|
585
588
|
try {
|
|
586
589
|
if (data) {
|
|
587
590
|
const parsedData = import_js_yaml.default.load(data);
|
|
588
|
-
|
|
591
|
+
this._logger.debug("Parsed yaml data successfully");
|
|
589
592
|
return { yaml: parsedData ?? null, errors: null };
|
|
590
593
|
}
|
|
591
594
|
} catch (error) {
|
|
@@ -610,10 +613,15 @@ var ConfigurationHandler = class {
|
|
|
610
613
|
return isGithubPlugin(plugin) ? this._fetchActionManifest(plugin) : this._fetchWorkerManifest(plugin);
|
|
611
614
|
}
|
|
612
615
|
async _fetchWorkerManifest(url) {
|
|
613
|
-
|
|
614
|
-
|
|
616
|
+
const manifestUrl = resolveManifestUrl(url);
|
|
617
|
+
if (!manifestUrl) {
|
|
618
|
+
this._logger.warn("Invalid plugin URL; cannot fetch manifest", { pluginUrl: url });
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
const manifestKey = `url:${manifestUrl}`;
|
|
622
|
+
if (this._manifestCache[manifestKey]) {
|
|
623
|
+
return this._manifestCache[manifestKey];
|
|
615
624
|
}
|
|
616
|
-
const manifestUrl = `${url}/manifest.json`;
|
|
617
625
|
try {
|
|
618
626
|
const result = await fetch(manifestUrl);
|
|
619
627
|
if (!result.ok) {
|
|
@@ -622,7 +630,7 @@ var ConfigurationHandler = class {
|
|
|
622
630
|
}
|
|
623
631
|
const jsonData = await result.json();
|
|
624
632
|
const manifest = this._decodeManifest(jsonData);
|
|
625
|
-
this._manifestCache[
|
|
633
|
+
this._manifestCache[manifestKey] = manifest;
|
|
626
634
|
return manifest;
|
|
627
635
|
} catch (e) {
|
|
628
636
|
this._logger.error("Could not find a manifest for Worker", { manifestUrl, err: e });
|
|
@@ -693,7 +701,7 @@ var ConfigurationHandler = class {
|
|
|
693
701
|
return manifest;
|
|
694
702
|
}
|
|
695
703
|
} catch (e) {
|
|
696
|
-
this._logger.warn(
|
|
704
|
+
this._logger.warn(`Could not find a valid manifest for ${owner}/${repo}${ref ? "@" + ref : ""}`, { owner, repo, ref, err: e });
|
|
697
705
|
}
|
|
698
706
|
return null;
|
|
699
707
|
})();
|
package/dist/configuration.mjs
CHANGED
|
@@ -136,6 +136,9 @@ function resolveManifestUrl(pluginUrl) {
|
|
|
136
136
|
while (pathname.endsWith("/") && pathname.length > 1) {
|
|
137
137
|
pathname = pathname.slice(0, -1);
|
|
138
138
|
}
|
|
139
|
+
if (pathname === "/") {
|
|
140
|
+
pathname = EMPTY_STRING;
|
|
141
|
+
}
|
|
139
142
|
if (pathname.endsWith(".json")) {
|
|
140
143
|
parsed.search = EMPTY_STRING;
|
|
141
144
|
parsed.hash = EMPTY_STRING;
|
|
@@ -423,7 +426,7 @@ var ConfigurationHandler = class {
|
|
|
423
426
|
return { config: targetRepoConfiguration, imports, errors, rawData };
|
|
424
427
|
}
|
|
425
428
|
_decodeConfiguration(location, config) {
|
|
426
|
-
this._logger.
|
|
429
|
+
this._logger.debug("Decoding configuration", { owner: location.owner, repository: location.repo });
|
|
427
430
|
try {
|
|
428
431
|
const configSchemaWithDefaults = Value.Default(configSchema, config);
|
|
429
432
|
const errors = Value.Errors(configSchema, configSchemaWithDefaults);
|
|
@@ -518,7 +521,7 @@ var ConfigurationHandler = class {
|
|
|
518
521
|
...ref ? { ref } : {},
|
|
519
522
|
mediaType: { format: "raw" }
|
|
520
523
|
});
|
|
521
|
-
|
|
524
|
+
this._logger.debug("Configuration file found", { owner, repository, filePath, rateLimitRemaining: headers?.["x-ratelimit-remaining"] });
|
|
522
525
|
return data;
|
|
523
526
|
} catch (err) {
|
|
524
527
|
this._handleDownloadError(err, { owner, repository, filePath });
|
|
@@ -542,11 +545,11 @@ var ConfigurationHandler = class {
|
|
|
542
545
|
* Parse the raw YAML content and returns the loaded YAML, or errors if any.
|
|
543
546
|
*/
|
|
544
547
|
parseYaml(data) {
|
|
545
|
-
this._logger.
|
|
548
|
+
this._logger.debug("Will attempt to parse YAML data");
|
|
546
549
|
try {
|
|
547
550
|
if (data) {
|
|
548
551
|
const parsedData = YAML.load(data);
|
|
549
|
-
|
|
552
|
+
this._logger.debug("Parsed yaml data successfully");
|
|
550
553
|
return { yaml: parsedData ?? null, errors: null };
|
|
551
554
|
}
|
|
552
555
|
} catch (error) {
|
|
@@ -571,10 +574,15 @@ var ConfigurationHandler = class {
|
|
|
571
574
|
return isGithubPlugin(plugin) ? this._fetchActionManifest(plugin) : this._fetchWorkerManifest(plugin);
|
|
572
575
|
}
|
|
573
576
|
async _fetchWorkerManifest(url) {
|
|
574
|
-
|
|
575
|
-
|
|
577
|
+
const manifestUrl = resolveManifestUrl(url);
|
|
578
|
+
if (!manifestUrl) {
|
|
579
|
+
this._logger.warn("Invalid plugin URL; cannot fetch manifest", { pluginUrl: url });
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
const manifestKey = `url:${manifestUrl}`;
|
|
583
|
+
if (this._manifestCache[manifestKey]) {
|
|
584
|
+
return this._manifestCache[manifestKey];
|
|
576
585
|
}
|
|
577
|
-
const manifestUrl = `${url}/manifest.json`;
|
|
578
586
|
try {
|
|
579
587
|
const result = await fetch(manifestUrl);
|
|
580
588
|
if (!result.ok) {
|
|
@@ -583,7 +591,7 @@ var ConfigurationHandler = class {
|
|
|
583
591
|
}
|
|
584
592
|
const jsonData = await result.json();
|
|
585
593
|
const manifest = this._decodeManifest(jsonData);
|
|
586
|
-
this._manifestCache[
|
|
594
|
+
this._manifestCache[manifestKey] = manifest;
|
|
587
595
|
return manifest;
|
|
588
596
|
} catch (e) {
|
|
589
597
|
this._logger.error("Could not find a manifest for Worker", { manifestUrl, err: e });
|
|
@@ -654,7 +662,7 @@ var ConfigurationHandler = class {
|
|
|
654
662
|
return manifest;
|
|
655
663
|
}
|
|
656
664
|
} catch (e) {
|
|
657
|
-
this._logger.warn(
|
|
665
|
+
this._logger.warn(`Could not find a valid manifest for ${owner}/${repo}${ref ? "@" + ref : ""}`, { owner, repo, ref, err: e });
|
|
658
666
|
}
|
|
659
667
|
return null;
|
|
660
668
|
})();
|