@fias/plugin-dev-harness 1.8.1 → 1.9.0
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/cli/preflight-client.d.ts +50 -0
- package/dist/cli/preflight-client.d.ts.map +1 -0
- package/dist/cli/preflight-client.js +80 -0
- package/dist/cli/preflight-client.js.map +1 -0
- package/dist/cli/submit.d.ts.map +1 -1
- package/dist/cli/submit.js +63 -6
- package/dist/cli/submit.js.map +1 -1
- package/dist/cli/submit.test.js +9 -0
- package/dist/cli/submit.test.js.map +1 -1
- package/dist/cli/version.d.ts +47 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +143 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli/version.test.d.ts +2 -0
- package/dist/cli/version.test.d.ts.map +1 -0
- package/dist/cli/version.test.js +164 -0
- package/dist/cli/version.test.js.map +1 -0
- package/dist/server/harness-server.d.ts.map +1 -1
- package/dist/server/harness-server.js +121 -5
- package/dist/server/harness-server.js.map +1 -1
- package/dist/server/harness-server.test.js +17 -4
- package/dist/server/harness-server.test.js.map +1 -1
- package/dist/server/static/harness.css +28 -0
- package/dist/server/static/harness.html +1 -0
- package/dist/server/static/harness.js +125 -10
- package/package.json +4 -2
|
@@ -810,26 +810,141 @@
|
|
|
810
810
|
document.getElementById('pub-build-output').textContent = '';
|
|
811
811
|
document.getElementById('pub-submit-progress').innerHTML = '';
|
|
812
812
|
|
|
813
|
-
//
|
|
813
|
+
// The server is the single source of truth for the publish fee. We ask
|
|
814
|
+
// the preflight endpoint (which knows whether this plugin's arche has
|
|
815
|
+
// ever been listed before) and render whatever it tells us. Never
|
|
816
|
+
// hardcode dollar amounts here — they will drift.
|
|
814
817
|
Promise.all([
|
|
815
|
-
fetch('/api/publish/
|
|
818
|
+
fetch('/api/publish/preflight-version', {
|
|
819
|
+
method: 'POST',
|
|
820
|
+
headers: { 'Content-Type': 'application/json' },
|
|
821
|
+
body: JSON.stringify({ bumpKind: 'patch' }),
|
|
822
|
+
}).then(function (r) { return r.ok ? r.json() : null; }),
|
|
816
823
|
fetch('/api/credits').then(function (r) { return r.json(); }),
|
|
817
824
|
]).then(function (results) {
|
|
818
|
-
var
|
|
825
|
+
var preflight = results[0];
|
|
819
826
|
var creditsData = results[1];
|
|
820
|
-
var existingCount = (subsData.submissions || []).length;
|
|
821
|
-
var isUpdate = existingCount > 0;
|
|
822
|
-
var cost = isUpdate ? '100 credits ($1.00)' : '5,000 credits ($50.00)';
|
|
823
|
-
var costType = isUpdate ? 'Update' : 'First listing';
|
|
824
827
|
|
|
825
|
-
|
|
828
|
+
var html;
|
|
829
|
+
if (preflight && preflight.feeCents != null) {
|
|
830
|
+
var feeCents = preflight.feeCents;
|
|
831
|
+
var costLabel =
|
|
832
|
+
(feeCents).toLocaleString() + ' credits ($' + (feeCents / 100).toFixed(2) + ')';
|
|
833
|
+
var costType = preflight.isFirstListing ? 'First listing' : 'Update';
|
|
834
|
+
html = '<p>' + costType + ' cost: <strong>' + costLabel + '</strong></p>';
|
|
835
|
+
if (preflight.refundableCents) {
|
|
836
|
+
html +=
|
|
837
|
+
'<p style="font-size:12px;color:#a1a1aa;margin-top:4px">' +
|
|
838
|
+
'$' + (preflight.refundableCents / 100).toFixed(2) +
|
|
839
|
+
' refunded automatically if the review rejects your submission.</p>';
|
|
840
|
+
}
|
|
841
|
+
} else {
|
|
842
|
+
// Older API or preflight unavailable — describe the model in words
|
|
843
|
+
// rather than guessing a number that might be wrong.
|
|
844
|
+
html = '<p>Submission cost will be confirmed by the server when you submit.</p>';
|
|
845
|
+
}
|
|
826
846
|
|
|
827
847
|
if (creditsData.balance != null && isFinite(creditsData.balance)) {
|
|
828
|
-
|
|
848
|
+
html +=
|
|
849
|
+
'<p style="margin-top:8px">Your balance: <strong>' +
|
|
850
|
+
creditsData.balance.toFixed(2) + ' credits</strong></p>';
|
|
829
851
|
}
|
|
852
|
+
costEl.innerHTML = html;
|
|
830
853
|
}).catch(function () {
|
|
831
|
-
costEl.innerHTML = '<p>Submission cost
|
|
854
|
+
costEl.innerHTML = '<p>Submission cost will be confirmed by the server when you submit.</p>';
|
|
832
855
|
});
|
|
856
|
+
|
|
857
|
+
showVersionInfo();
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
// Asks the server "what version will I publish as?" and shows a banner so
|
|
861
|
+
// the user is never surprised by an auto-bump. The actual write to disk
|
|
862
|
+
// happens server-side during /api/publish/package — this preview is read-
|
|
863
|
+
// only. The override link routes back to step 1 where they can edit
|
|
864
|
+
// pricing/about and the version field via the form.
|
|
865
|
+
function showVersionInfo() {
|
|
866
|
+
var versionEl = document.getElementById('pub-version-info');
|
|
867
|
+
versionEl.style.display = 'none';
|
|
868
|
+
versionEl.innerHTML = '';
|
|
869
|
+
|
|
870
|
+
fetch('/api/publish/preflight-version', {
|
|
871
|
+
method: 'POST',
|
|
872
|
+
headers: { 'Content-Type': 'application/json' },
|
|
873
|
+
body: JSON.stringify({ bumpKind: 'patch' }),
|
|
874
|
+
})
|
|
875
|
+
.then(function (r) { return r.ok ? r.json() : null; })
|
|
876
|
+
.then(function (data) {
|
|
877
|
+
if (!data || data.available === false) return;
|
|
878
|
+
versionEl.style.display = 'block';
|
|
879
|
+
var html;
|
|
880
|
+
if (data.wasAutoBumped) {
|
|
881
|
+
html =
|
|
882
|
+
'<p>Will publish as <strong>v' + escapeHtml(data.submittedVersion) + '</strong>' +
|
|
883
|
+
' (latest published: <strong>v' + escapeHtml(data.latestPublishedVersion || '—') + '</strong>).</p>' +
|
|
884
|
+
'<p style="font-size:12px;color:#a1a1aa;margin-top:4px">' +
|
|
885
|
+
'Auto-bumped from v' + escapeHtml(data.previousVersion) +
|
|
886
|
+
'. <a href="#" id="pub-version-override-link">Override</a></p>';
|
|
887
|
+
} else if (data.action === 'explicit' || data.previousVersion === data.submittedVersion) {
|
|
888
|
+
html =
|
|
889
|
+
'<p>Submitting as <strong>v' + escapeHtml(data.submittedVersion) + '</strong>' +
|
|
890
|
+
(data.latestPublishedVersion
|
|
891
|
+
? ' (latest published: <strong>v' + escapeHtml(data.latestPublishedVersion) + '</strong>)'
|
|
892
|
+
: '') + '.</p>' +
|
|
893
|
+
'<p style="font-size:12px;color:#a1a1aa;margin-top:4px">' +
|
|
894
|
+
'Manifest version respected. <a href="#" id="pub-version-override-link">Override</a></p>';
|
|
895
|
+
} else {
|
|
896
|
+
html =
|
|
897
|
+
'<p>Will publish as <strong>v' + escapeHtml(data.submittedVersion) + '</strong>.</p>' +
|
|
898
|
+
'<p style="font-size:12px;color:#a1a1aa;margin-top:4px">' +
|
|
899
|
+
'<a href="#" id="pub-version-override-link">Override</a></p>';
|
|
900
|
+
}
|
|
901
|
+
versionEl.innerHTML = html;
|
|
902
|
+
var override = document.getElementById('pub-version-override-link');
|
|
903
|
+
if (override) {
|
|
904
|
+
override.addEventListener('click', function (e) {
|
|
905
|
+
e.preventDefault();
|
|
906
|
+
promptVersionOverride(data);
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
})
|
|
910
|
+
.catch(function () { /* preflight is best-effort; silently skip */ });
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
function promptVersionOverride(data) {
|
|
914
|
+
var current = data.submittedVersion;
|
|
915
|
+
var input = window.prompt(
|
|
916
|
+
'Enter the version to publish as (e.g., 1.2.3 or 1.2.3-beta.1):',
|
|
917
|
+
current,
|
|
918
|
+
);
|
|
919
|
+
if (!input || input === current) return;
|
|
920
|
+
fetch('/api/publish/preflight-version', {
|
|
921
|
+
method: 'POST',
|
|
922
|
+
headers: { 'Content-Type': 'application/json' },
|
|
923
|
+
body: JSON.stringify({ explicitVersion: input.trim() }),
|
|
924
|
+
})
|
|
925
|
+
.then(function (r) { return r.json().then(function (b) { return { ok: r.ok, body: b }; }); })
|
|
926
|
+
.then(function (resp) {
|
|
927
|
+
if (!resp.ok) {
|
|
928
|
+
window.alert(resp.body.error || 'Invalid version.');
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
// Persist the override to fias-plugin.json so /api/publish/package
|
|
932
|
+
// sees it as the manifest version. The decideNextVersion logic on
|
|
933
|
+
// the server will then "respect" it (manifest > latest, or pre-
|
|
934
|
+
// release) and not re-bump.
|
|
935
|
+
fetch('/api/manifest', { method: 'GET' })
|
|
936
|
+
.then(function (r) { return r.json(); })
|
|
937
|
+
.then(function (manifest) {
|
|
938
|
+
manifest.version = input.trim();
|
|
939
|
+
return fetch('/api/manifest', {
|
|
940
|
+
method: 'PUT',
|
|
941
|
+
headers: { 'Content-Type': 'application/json' },
|
|
942
|
+
body: JSON.stringify(manifest),
|
|
943
|
+
});
|
|
944
|
+
})
|
|
945
|
+
.then(function () { showVersionInfo(); });
|
|
946
|
+
})
|
|
947
|
+
.catch(function () { window.alert('Could not validate version.'); });
|
|
833
948
|
}
|
|
834
949
|
|
|
835
950
|
function startBuildAndSubmit() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fias/plugin-dev-harness",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Development harness for building and testing FIAS plugin arches locally",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
"@fias/arche-sdk": "^1.0.0",
|
|
34
34
|
"chalk": "^4.1.2",
|
|
35
35
|
"commander": "^12.0.0",
|
|
36
|
-
"express": "^4.21.0"
|
|
36
|
+
"express": "^4.21.0",
|
|
37
|
+
"semver": "^7.7.3"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/express": "^5.0.0",
|
|
40
41
|
"@types/node": "^25.5.0",
|
|
42
|
+
"@types/semver": "^7.7.0",
|
|
41
43
|
"typescript": "^5.3.3"
|
|
42
44
|
}
|
|
43
45
|
}
|