@happyvertical/smrt-cli 0.57.29 → 0.57.31
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/{AuditLogCollection-BBbvr8Qc-BLKAC_lt.js → AuditLogCollection-BBbvr8Qc-CS-pwR93.js} +1 -1
- package/dist/{OidcIdentity-MVVO3MfG-NRsZDEk0.js → OidcIdentity-MVVO3MfG-CW0gRjHH.js} +2 -2
- package/dist/{OidcIdentityCollection-s4mp3n62-Bg2JYzW0.js → OidcIdentityCollection-s4mp3n62-DTnGCBp_.js} +1 -1
- package/dist/{PasswordCredentialService-DA2Y6H2X-u6IgiDQg.js → PasswordCredentialService-DA2Y6H2X-C1wDQMMz.js} +14 -14
- package/dist/{ProfileAssetCollection-BuVAdOiv-CnTWWD-r.js → ProfileAssetCollection-BuVAdOiv-Cd9LYnjq.js} +3 -3
- package/dist/{ProfileCollection-CMS9dFc0-DnrPHwYV.js → ProfileCollection-CMS9dFc0-ou6DCuSN.js} +17 -17
- package/dist/{ProfileLinkCollection-ChK9iEBp-DJpdQldn.js → ProfileLinkCollection-ChK9iEBp-DsyUTF9k.js} +2 -2
- package/dist/{ProfileMetadataCollection-CAgJyjze-9ieKExQ-.js → ProfileMetadataCollection-CAgJyjze-D-MPBgxA.js} +1 -1
- package/dist/{ProfileMetafieldCollection-19ae6Lpf-B2GKm3WL.js → ProfileMetafieldCollection-19ae6Lpf-CHnbYx6c.js} +1 -1
- package/dist/{ProfileRelationshipCollection-BFSlTQ7J-D56AsFiv.js → ProfileRelationshipCollection-BFSlTQ7J-DAkdWzku.js} +1 -1
- package/dist/{ProfileTypeCollection-B7m698Bl-qp8nqwFe.js → ProfileTypeCollection-B7m698Bl-DxyyJbnp.js} +2 -2
- package/dist/{commands-CSHb5B5i.js → commands-CGjKkRkb.js} +3 -3
- package/dist/{dist-BXBuCfoQ.js → dist-0W96Ab-B.js} +3 -3
- package/dist/{dist-dCopPDeN.js → dist-BlRecRqP.js} +5 -5
- package/dist/{dist-BMxFUu5j.js → dist-Cl_Woozo.js} +2 -2
- package/dist/{dist-B5qhNGmn.js → dist-DP_7RmP6.js} +4 -4
- package/dist/index.js +11 -11
- package/dist/{oidcProvisioningPrimitives-Dl9qIcYS-CMn20Sa_.js → oidcProvisioningPrimitives-Dl9qIcYS-CPuL4amA.js} +3 -3
- package/dist/{operator-BbtzrspR.js → operator-XENg78bg.js} +2 -2
- package/dist/{resolveIdentity-CR5p_g7K-DW6s3Fdt.js → resolveIdentity-CR5p_g7K-XIGHZpkd.js} +14 -14
- package/package.json +15 -15
- package/scripts/verify-package-types-exports.js +247 -14
package/dist/index.js
CHANGED
|
@@ -51,77 +51,77 @@ var _cookbookCommands = null;
|
|
|
51
51
|
var _kitchenCommands = null;
|
|
52
52
|
async function getGnodeCommands() {
|
|
53
53
|
if (!_gnodeCommands) {
|
|
54
|
-
const { gnodeCommands } = await import("./commands-
|
|
54
|
+
const { gnodeCommands } = await import("./commands-CGjKkRkb.js");
|
|
55
55
|
_gnodeCommands = gnodeCommands;
|
|
56
56
|
}
|
|
57
57
|
return _gnodeCommands;
|
|
58
58
|
}
|
|
59
59
|
async function getGitCommands() {
|
|
60
60
|
if (!_gitCommands) {
|
|
61
|
-
const { gitCommands } = await import("./commands-
|
|
61
|
+
const { gitCommands } = await import("./commands-CGjKkRkb.js");
|
|
62
62
|
_gitCommands = gitCommands;
|
|
63
63
|
}
|
|
64
64
|
return _gitCommands;
|
|
65
65
|
}
|
|
66
66
|
async function getGenerateCommands() {
|
|
67
67
|
if (!_generateCommands) {
|
|
68
|
-
const { generateCommands } = await import("./commands-
|
|
68
|
+
const { generateCommands } = await import("./commands-CGjKkRkb.js");
|
|
69
69
|
_generateCommands = generateCommands;
|
|
70
70
|
}
|
|
71
71
|
return _generateCommands;
|
|
72
72
|
}
|
|
73
73
|
async function getInitCommands() {
|
|
74
74
|
if (!_initCommands) {
|
|
75
|
-
const { initCommands } = await import("./commands-
|
|
75
|
+
const { initCommands } = await import("./commands-CGjKkRkb.js");
|
|
76
76
|
_initCommands = initCommands;
|
|
77
77
|
}
|
|
78
78
|
return _initCommands;
|
|
79
79
|
}
|
|
80
80
|
async function getUtilityCommands() {
|
|
81
81
|
if (!_utilityCommands) {
|
|
82
|
-
const { utilityCommands } = await import("./commands-
|
|
82
|
+
const { utilityCommands } = await import("./commands-CGjKkRkb.js");
|
|
83
83
|
_utilityCommands = utilityCommands;
|
|
84
84
|
}
|
|
85
85
|
return _utilityCommands;
|
|
86
86
|
}
|
|
87
87
|
async function getDispatchCommands() {
|
|
88
88
|
if (!_dispatchCommands) {
|
|
89
|
-
const { dispatchCommands } = await import("./commands-
|
|
89
|
+
const { dispatchCommands } = await import("./commands-CGjKkRkb.js");
|
|
90
90
|
_dispatchCommands = dispatchCommands;
|
|
91
91
|
}
|
|
92
92
|
return _dispatchCommands;
|
|
93
93
|
}
|
|
94
94
|
async function getDocsCommands() {
|
|
95
95
|
if (!_docsCommands) {
|
|
96
|
-
const { docsCommands } = await import("./commands-
|
|
96
|
+
const { docsCommands } = await import("./commands-CGjKkRkb.js");
|
|
97
97
|
_docsCommands = docsCommands;
|
|
98
98
|
}
|
|
99
99
|
return _docsCommands;
|
|
100
100
|
}
|
|
101
101
|
async function getPlaygroundCommands() {
|
|
102
102
|
if (!_playgroundCommands) {
|
|
103
|
-
const { playgroundCommands } = await import("./commands-
|
|
103
|
+
const { playgroundCommands } = await import("./commands-CGjKkRkb.js");
|
|
104
104
|
_playgroundCommands = playgroundCommands;
|
|
105
105
|
}
|
|
106
106
|
return _playgroundCommands;
|
|
107
107
|
}
|
|
108
108
|
async function getCookbookCommands() {
|
|
109
109
|
if (!_cookbookCommands) {
|
|
110
|
-
const { cookbookCommands } = await import("./commands-
|
|
110
|
+
const { cookbookCommands } = await import("./commands-CGjKkRkb.js");
|
|
111
111
|
_cookbookCommands = cookbookCommands;
|
|
112
112
|
}
|
|
113
113
|
return _cookbookCommands;
|
|
114
114
|
}
|
|
115
115
|
async function getKitchenCommands() {
|
|
116
116
|
if (!_kitchenCommands) {
|
|
117
|
-
const { kitchenCommands } = await import("./commands-
|
|
117
|
+
const { kitchenCommands } = await import("./commands-CGjKkRkb.js");
|
|
118
118
|
_kitchenCommands = kitchenCommands;
|
|
119
119
|
}
|
|
120
120
|
return _kitchenCommands;
|
|
121
121
|
}
|
|
122
122
|
async function getWorkbenchCommands() {
|
|
123
123
|
if (!_workbenchCommands) {
|
|
124
|
-
const { workbenchCommands } = await import("./commands-
|
|
124
|
+
const { workbenchCommands } = await import("./commands-CGjKkRkb.js");
|
|
125
125
|
_workbenchCommands = workbenchCommands;
|
|
126
126
|
}
|
|
127
127
|
return _workbenchCommands;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
2
|
import { n as __exportAll$1 } from "./NostrIdentity-RJaATTCt-BbRHWyee.js";
|
|
3
|
-
import { t as OidcIdentity } from "./OidcIdentity-MVVO3MfG-
|
|
4
|
-
import { c as saveOidcRaceArbiter, n as ProfileCollection, t as Profile } from "./ProfileCollection-CMS9dFc0-
|
|
5
|
-
import { t as ProfileTypeCollection } from "./ProfileTypeCollection-B7m698Bl-
|
|
3
|
+
import { t as OidcIdentity } from "./OidcIdentity-MVVO3MfG-CW0gRjHH.js";
|
|
4
|
+
import { c as saveOidcRaceArbiter, n as ProfileCollection, t as Profile } from "./ProfileCollection-CMS9dFc0-ou6DCuSN.js";
|
|
5
|
+
import { t as ProfileTypeCollection } from "./ProfileTypeCollection-B7m698Bl-DxyyJbnp.js";
|
|
6
6
|
import { smrt } from "@happyvertical/smrt-core";
|
|
7
7
|
//#region ../profiles/dist/chunks/oidcProvisioningPrimitives-Dl9qIcYS.js
|
|
8
8
|
var oidcProvisioningPrimitives_Dl9qIcYS_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as withSystemContext } from "./dist-
|
|
2
|
-
import { Ct as TenantStatus, E as PasswordCredentialService, K as UserCollection, N as RoleCollection, Q as UsersPasswordCredentialCollection, V as TenantCollection, dt as normalizeUsername, g as MembershipCollection, ht as verifySecretHash, j as PermissionResolver, lt as normalizeEmail, st as isValidEmail, wt as UserStatus, yt as MembershipStatus } from "./PasswordCredentialService-DA2Y6H2X-
|
|
1
|
+
import { m as withSystemContext } from "./dist-Cl_Woozo.js";
|
|
2
|
+
import { Ct as TenantStatus, E as PasswordCredentialService, K as UserCollection, N as RoleCollection, Q as UsersPasswordCredentialCollection, V as TenantCollection, dt as normalizeUsername, g as MembershipCollection, ht as verifySecretHash, j as PermissionResolver, lt as normalizeEmail, st as isValidEmail, wt as UserStatus, yt as MembershipStatus } from "./PasswordCredentialService-DA2Y6H2X-C1wDQMMz.js";
|
|
3
3
|
import { isPostgresDatabase, withEmbeddedWriteTransaction } from "@happyvertical/smrt-core";
|
|
4
4
|
//#region ../users/dist/operator.js
|
|
5
5
|
var OperatorProvisioningError = class extends Error {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { m as withSystemContext } from "./dist-
|
|
2
|
+
import { m as withSystemContext } from "./dist-Cl_Woozo.js";
|
|
3
3
|
import { a as verifyAuthEvent, n as __exportAll$1, t as NostrIdentity } from "./NostrIdentity-RJaATTCt-BbRHWyee.js";
|
|
4
4
|
import { t as ApiKey } from "./ApiKey-9YuYcpWy-BdrXOe-N.js";
|
|
5
|
-
import { t as OidcIdentity } from "./OidcIdentity-MVVO3MfG-
|
|
6
|
-
import { a as coordinateOidcProvisioning, o as isOidcProvisioningRaceConflict, s as normalizeIdentityEmail } from "./ProfileCollection-CMS9dFc0-
|
|
7
|
-
import { n as insertOidcProvisioningIdentity, t as createOidcProvisioningPerson } from "./oidcProvisioningPrimitives-Dl9qIcYS-
|
|
5
|
+
import { t as OidcIdentity } from "./OidcIdentity-MVVO3MfG-CW0gRjHH.js";
|
|
6
|
+
import { a as coordinateOidcProvisioning, o as isOidcProvisioningRaceConflict, s as normalizeIdentityEmail } from "./ProfileCollection-CMS9dFc0-ou6DCuSN.js";
|
|
7
|
+
import { n as insertOidcProvisioningIdentity, t as createOidcProvisioningPerson } from "./oidcProvisioningPrimitives-Dl9qIcYS-CPuL4amA.js";
|
|
8
8
|
import { resolveDatabase } from "@happyvertical/smrt-core";
|
|
9
9
|
//#region ../profiles/dist/chunks/resolveIdentity-CR5p_g7K.js
|
|
10
10
|
var resolveIdentity_CR5p_g7K_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -72,13 +72,13 @@ async function resolveIdentity(context) {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
async function findProfileByExternalId(provider, externalId, options) {
|
|
75
|
-
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-s4mp3n62-
|
|
75
|
+
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-s4mp3n62-DTnGCBp_.js").then((n) => n.r).then((n) => n.r);
|
|
76
76
|
const identities = await (await OidcIdentityCollection.create(options)).findByProvider(provider);
|
|
77
77
|
for (const identity of identities) if (identity.subject === externalId || identity.email?.includes(externalId)) {
|
|
78
78
|
const profile = await identity.getProfile();
|
|
79
79
|
if (profile) return profile;
|
|
80
80
|
}
|
|
81
|
-
const { ProfileCollection } = await import("./ProfileCollection-CMS9dFc0-
|
|
81
|
+
const { ProfileCollection } = await import("./ProfileCollection-CMS9dFc0-ou6DCuSN.js").then((n) => n.r).then((n) => n.r);
|
|
82
82
|
const profiles = await (await ProfileCollection.create(options)).list({
|
|
83
83
|
where: { email: `${externalId}@users.noreply.github.com` },
|
|
84
84
|
limit: 1
|
|
@@ -99,7 +99,7 @@ async function reuseExistingOidcIdentityForProfile(profileId, claims, provider,
|
|
|
99
99
|
createConcurrencyError: (cause) => new Error("Concurrent exact OIDC identity reuse did not converge.", cause === void 0 ? void 0 : { cause }),
|
|
100
100
|
rebindRootResult: rebindOidcProfileResult,
|
|
101
101
|
provision: (tx) => withSystemContext(async () => {
|
|
102
|
-
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-s4mp3n62-
|
|
102
|
+
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-s4mp3n62-DTnGCBp_.js").then((n) => n.r).then((n) => n.r);
|
|
103
103
|
const identity = await (await OidcIdentityCollection.create({ db: tx })).findBySubject(normalizedClaims.iss, normalizedClaims.sub);
|
|
104
104
|
if (!identity) throw new Error("OidcIdentity.findOrCreate() no longer creates authentication links; use UserCollection.getOrCreateFromOidc() or createProfileFromOidc().");
|
|
105
105
|
if (identity.profileId !== profileId) throw new Error(`OIDC identity ${normalizedClaims.iss} subject ${normalizedClaims.sub} belongs to a different Profile.`);
|
|
@@ -133,7 +133,7 @@ async function coordinateProfileOidcProvisioning(claims, provider, options) {
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
async function provisionOidcProfile(claims, provider, options) {
|
|
136
|
-
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-s4mp3n62-
|
|
136
|
+
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-s4mp3n62-DTnGCBp_.js").then((n) => n.r).then((n) => n.r);
|
|
137
137
|
const existingIdentity = await (await OidcIdentityCollection.create(options)).findBySubject(claims.iss, claims.sub);
|
|
138
138
|
if (existingIdentity) {
|
|
139
139
|
const profile2 = await existingIdentity.getProfile();
|
|
@@ -148,7 +148,7 @@ async function provisionOidcProfile(claims, provider, options) {
|
|
|
148
148
|
created: false
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
const { ProfileCollection } = await import("./ProfileCollection-CMS9dFc0-
|
|
151
|
+
const { ProfileCollection } = await import("./ProfileCollection-CMS9dFc0-ou6DCuSN.js").then((n) => n.r).then((n) => n.r);
|
|
152
152
|
const profileCollection = await ProfileCollection.create(options);
|
|
153
153
|
if (claims.email) {
|
|
154
154
|
if (await profileCollection.findUniqueGlobalPersonByEmail(claims.email)) {
|
|
@@ -175,8 +175,8 @@ async function provisionOidcProfile(claims, provider, options) {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
async function rebindOidcProfileResult(result, rootDb) {
|
|
178
|
-
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-s4mp3n62-
|
|
179
|
-
const { ProfileCollection } = await import("./ProfileCollection-CMS9dFc0-
|
|
178
|
+
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-s4mp3n62-DTnGCBp_.js").then((n) => n.r).then((n) => n.r);
|
|
179
|
+
const { ProfileCollection } = await import("./ProfileCollection-CMS9dFc0-ou6DCuSN.js").then((n) => n.r).then((n) => n.r);
|
|
180
180
|
const profileId = requireOidcProfileId(result.profile.id);
|
|
181
181
|
const identityId = requireOidcProfileId(result.oidcIdentity.id);
|
|
182
182
|
const [profile, oidcIdentity] = await withSystemContext(async () => {
|
|
@@ -225,11 +225,11 @@ async function createProfileFromNostr(email, nostrData, options) {
|
|
|
225
225
|
created: false
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
const { Person } = await import("./oidcProvisioningPrimitives-Dl9qIcYS-
|
|
229
|
-
const { ProfileTypeCollection } = await import("./ProfileTypeCollection-B7m698Bl-
|
|
228
|
+
const { Person } = await import("./oidcProvisioningPrimitives-Dl9qIcYS-CPuL4amA.js").then((n) => n.r).then((n) => n.o);
|
|
229
|
+
const { ProfileTypeCollection } = await import("./ProfileTypeCollection-B7m698Bl-DxyyJbnp.js").then((n) => n.n).then((n) => n.n);
|
|
230
230
|
let personType = await (await ProfileTypeCollection.create(options)).getBySlug("person");
|
|
231
231
|
if (!personType) {
|
|
232
|
-
const { ProfileType } = await import("./ProfileCollection-CMS9dFc0-
|
|
232
|
+
const { ProfileType } = await import("./ProfileCollection-CMS9dFc0-ou6DCuSN.js").then((n) => n.r).then((n) => n.h);
|
|
233
233
|
personType = new ProfileType({
|
|
234
234
|
...options,
|
|
235
235
|
slug: "person",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-cli",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.31",
|
|
4
4
|
"description": "Developer CLI for SMRT framework - introspection, testing, and project management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@happyvertical/ai": "^0.
|
|
34
|
-
"@happyvertical/files": "^0.
|
|
35
|
-
"@happyvertical/logger": "^0.
|
|
36
|
-
"@happyvertical/smrt-agents": "0.57.
|
|
37
|
-
"@happyvertical/smrt-app-runtime": "0.57.
|
|
38
|
-
"@happyvertical/smrt-config": "0.57.
|
|
39
|
-
"@happyvertical/smrt-core": "0.57.
|
|
40
|
-
"@happyvertical/smrt-dev-mcp": "0.57.
|
|
41
|
-
"@happyvertical/smrt-ledgers": "0.57.
|
|
42
|
-
"@happyvertical/smrt-playground": "0.57.
|
|
43
|
-
"@happyvertical/smrt-types": "0.57.
|
|
44
|
-
"@happyvertical/smrt-users": "0.57.
|
|
45
|
-
"@happyvertical/sql": "^0.
|
|
46
|
-
"@happyvertical/utils": "^0.
|
|
33
|
+
"@happyvertical/ai": "^0.108.0",
|
|
34
|
+
"@happyvertical/files": "^0.108.0",
|
|
35
|
+
"@happyvertical/logger": "^0.108.0",
|
|
36
|
+
"@happyvertical/smrt-agents": "0.57.31",
|
|
37
|
+
"@happyvertical/smrt-app-runtime": "0.57.31",
|
|
38
|
+
"@happyvertical/smrt-config": "0.57.31",
|
|
39
|
+
"@happyvertical/smrt-core": "0.57.31",
|
|
40
|
+
"@happyvertical/smrt-dev-mcp": "0.57.31",
|
|
41
|
+
"@happyvertical/smrt-ledgers": "0.57.31",
|
|
42
|
+
"@happyvertical/smrt-playground": "0.57.31",
|
|
43
|
+
"@happyvertical/smrt-types": "0.57.31",
|
|
44
|
+
"@happyvertical/smrt-users": "0.57.31",
|
|
45
|
+
"@happyvertical/sql": "^0.108.0",
|
|
46
|
+
"@happyvertical/utils": "^0.108.0",
|
|
47
47
|
"@modelcontextprotocol/server": "2.3.1",
|
|
48
48
|
"acorn": "^8.18.0",
|
|
49
49
|
"fast-glob": "3.3.3",
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdtempSync,
|
|
7
|
+
readFileSync,
|
|
8
|
+
rmSync,
|
|
9
|
+
statSync,
|
|
10
|
+
} from 'node:fs';
|
|
5
11
|
import { tmpdir } from 'node:os';
|
|
6
12
|
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
7
13
|
import { parse } from 'acorn';
|
|
@@ -67,7 +73,7 @@ function collectTypePaths(packageJson) {
|
|
|
67
73
|
return [...typePaths].map((filePath) => filePath.replace(/^\.\//, ''));
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
function collectRuntimePaths(packageJson) {
|
|
76
|
+
function collectRuntimePaths(packageJson, resourceExports) {
|
|
71
77
|
const runtimePaths = new Set();
|
|
72
78
|
|
|
73
79
|
const addPath = (filePath) => {
|
|
@@ -104,7 +110,7 @@ function collectRuntimePaths(packageJson) {
|
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
for (const [key, child] of Object.entries(value)) {
|
|
107
|
-
visit(child, key);
|
|
113
|
+
if (!resourceExports.has(key)) visit(child, key);
|
|
108
114
|
}
|
|
109
115
|
};
|
|
110
116
|
|
|
@@ -131,6 +137,41 @@ function archiveHasPath(archiveEntries, relativePath) {
|
|
|
131
137
|
return [...archiveEntries].some((entry) => pattern.test(entry));
|
|
132
138
|
}
|
|
133
139
|
|
|
140
|
+
/** Resource declarations classify copied files, never runtime import edges. */
|
|
141
|
+
function collectResourceExports(packageJson, archiveEntries) {
|
|
142
|
+
const declared = packageJson.smrt?.resourceExports;
|
|
143
|
+
if (declared === undefined) return new Set();
|
|
144
|
+
if (!Array.isArray(declared))
|
|
145
|
+
fail(
|
|
146
|
+
'smrt.resourceExports must be an array of literal-directory export patterns',
|
|
147
|
+
);
|
|
148
|
+
const resources = new Set();
|
|
149
|
+
for (const subpath of declared) {
|
|
150
|
+
// Require a non-root directory and one terminal wildcard. An exact,
|
|
151
|
+
// unconditioned mapping prevents a declaration from hiding other branches.
|
|
152
|
+
if (
|
|
153
|
+
typeof subpath !== 'string' ||
|
|
154
|
+
!/^\.\/(?:[a-zA-Z0-9_-][a-zA-Z0-9._-]*\/)+\*$/.test(subpath) ||
|
|
155
|
+
resources.has(subpath) ||
|
|
156
|
+
packageJson.exports?.[subpath] !== subpath
|
|
157
|
+
) {
|
|
158
|
+
fail(
|
|
159
|
+
`Invalid smrt.resourceExports declaration: ${JSON.stringify(subpath)}; use a unique directory pattern such as "./template/*" with an identical unconditioned export target`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
const prefix = `package/${subpath.slice(2, -1)}`;
|
|
163
|
+
if (
|
|
164
|
+
![...archiveEntries].some(
|
|
165
|
+
(entry) => entry.startsWith(prefix) && !entry.endsWith('/'),
|
|
166
|
+
)
|
|
167
|
+
) {
|
|
168
|
+
fail(`smrt.resourceExports ${subpath} has no packed files`);
|
|
169
|
+
}
|
|
170
|
+
resources.add(subpath);
|
|
171
|
+
}
|
|
172
|
+
return resources;
|
|
173
|
+
}
|
|
174
|
+
|
|
134
175
|
function stripComments(source) {
|
|
135
176
|
return source
|
|
136
177
|
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
@@ -412,6 +453,191 @@ function collectMissingRelativeRuntimeImports(packageRoot, runtimeEntryFiles) {
|
|
|
412
453
|
return missing;
|
|
413
454
|
}
|
|
414
455
|
|
|
456
|
+
/** Inspect each exported runtime closure, never infer Svelte from its package. */
|
|
457
|
+
function verifySvelteExportConditions(
|
|
458
|
+
packageRoot,
|
|
459
|
+
packageJson,
|
|
460
|
+
archiveEntries,
|
|
461
|
+
resourceExports,
|
|
462
|
+
) {
|
|
463
|
+
const display = (path) => relative(packageRoot, path);
|
|
464
|
+
const reachesSvelte = (entryPath) => {
|
|
465
|
+
const pending = [entryPath];
|
|
466
|
+
const seen = new Set();
|
|
467
|
+
let marker;
|
|
468
|
+
while (pending.length) {
|
|
469
|
+
const filePath = pending.pop();
|
|
470
|
+
if (seen.has(filePath)) continue;
|
|
471
|
+
seen.add(filePath);
|
|
472
|
+
if (
|
|
473
|
+
!isWithinPackageRoot(packageRoot, filePath) ||
|
|
474
|
+
!existsSync(filePath) ||
|
|
475
|
+
!statSync(filePath).isFile()
|
|
476
|
+
) {
|
|
477
|
+
fail(
|
|
478
|
+
`Svelte export inspection cannot read packed target ${display(filePath)}`,
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
if (filePath.endsWith('.svelte')) {
|
|
482
|
+
marker ??= display(filePath);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if (!/\.[cm]?js$/.test(filePath)) continue;
|
|
486
|
+
let program;
|
|
487
|
+
try {
|
|
488
|
+
program = parse(readFileSync(filePath, 'utf8'), {
|
|
489
|
+
ecmaVersion: 'latest',
|
|
490
|
+
sourceType: 'module',
|
|
491
|
+
});
|
|
492
|
+
} catch (error) {
|
|
493
|
+
fail(
|
|
494
|
+
`Svelte export inspection cannot parse packed JavaScript ${display(filePath)}: ${error.message}`,
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
// Only static runtime edges. JS has no type-only imports; .d.ts targets
|
|
498
|
+
// and component script types never enter this parser.
|
|
499
|
+
for (const statement of program.body) {
|
|
500
|
+
if (
|
|
501
|
+
![
|
|
502
|
+
'ImportDeclaration',
|
|
503
|
+
'ExportNamedDeclaration',
|
|
504
|
+
'ExportAllDeclaration',
|
|
505
|
+
].includes(statement.type)
|
|
506
|
+
)
|
|
507
|
+
continue;
|
|
508
|
+
const specifier = statement.source?.value;
|
|
509
|
+
if (typeof specifier !== 'string') continue;
|
|
510
|
+
if (specifier === 'svelte' || specifier.startsWith('svelte/')) {
|
|
511
|
+
marker ??= `${display(filePath)} -> ${specifier}`;
|
|
512
|
+
}
|
|
513
|
+
if (!specifier.startsWith('.')) continue;
|
|
514
|
+
const target = resolve(
|
|
515
|
+
dirname(filePath),
|
|
516
|
+
specifier.replace(/[?#].*$/, ''),
|
|
517
|
+
);
|
|
518
|
+
if (!isWithinPackageRoot(packageRoot, target)) {
|
|
519
|
+
fail(
|
|
520
|
+
`Svelte export inspection found an escaping packed import: ${display(filePath)} -> ${specifier}`,
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
// Require exact emitted targets for explicit extensions. Do not silently
|
|
524
|
+
// substitute a neighbouring .js for a missing .mjs or component.
|
|
525
|
+
const resolved = /\.[^/]+$/.test(target)
|
|
526
|
+
? target
|
|
527
|
+
: findExistingPackageCandidate(
|
|
528
|
+
packageRoot,
|
|
529
|
+
target,
|
|
530
|
+
resolveRuntimeCandidates,
|
|
531
|
+
);
|
|
532
|
+
if (
|
|
533
|
+
!resolved ||
|
|
534
|
+
!existsSync(resolved) ||
|
|
535
|
+
!statSync(resolved).isFile()
|
|
536
|
+
) {
|
|
537
|
+
fail(
|
|
538
|
+
`Svelte export inspection missing packed import target: ${display(filePath)} -> ${specifier}`,
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
if (isRuntimeSourceFile(resolved)) pending.push(resolved);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return marker;
|
|
545
|
+
};
|
|
546
|
+
const packedTargets = (value) => {
|
|
547
|
+
const pattern = new RegExp(
|
|
548
|
+
`^${escapeRegex(`package/${value.slice(2)}`).replaceAll('*', '.*')}$`,
|
|
549
|
+
);
|
|
550
|
+
return value.includes('*')
|
|
551
|
+
? [...archiveEntries]
|
|
552
|
+
.filter((entry) => pattern.test(entry) && !entry.endsWith('/'))
|
|
553
|
+
.map((entry) => entry.slice(8))
|
|
554
|
+
: [value.slice(2)];
|
|
555
|
+
};
|
|
556
|
+
const validatedConditions = new WeakSet();
|
|
557
|
+
const validateSvelteTargets = (value, subpath) => {
|
|
558
|
+
if (value === null) return 0;
|
|
559
|
+
if (typeof value === 'string') {
|
|
560
|
+
if (!value.startsWith('./'))
|
|
561
|
+
fail(`Export ${subpath} has a non-relative svelte target: ${value}`);
|
|
562
|
+
const targets = packedTargets(value);
|
|
563
|
+
if (
|
|
564
|
+
!targets.length ||
|
|
565
|
+
targets.some((target) => !isRuntimeSourceFile(target))
|
|
566
|
+
)
|
|
567
|
+
fail(`Export ${subpath} has no usable packed svelte target: ${value}`);
|
|
568
|
+
for (const target of targets) reachesSvelte(resolve(packageRoot, target));
|
|
569
|
+
return targets.length;
|
|
570
|
+
}
|
|
571
|
+
const children = Array.isArray(value)
|
|
572
|
+
? value
|
|
573
|
+
: value && typeof value === 'object'
|
|
574
|
+
? Object.entries(value)
|
|
575
|
+
.filter(([key]) => key !== 'types' && !key.startsWith('types@'))
|
|
576
|
+
.map(([, child]) => child)
|
|
577
|
+
: [];
|
|
578
|
+
return children.reduce(
|
|
579
|
+
(count, child) => count + validateSvelteTargets(child, subpath),
|
|
580
|
+
0,
|
|
581
|
+
);
|
|
582
|
+
};
|
|
583
|
+
const inspect = (value, subpath, scopes = []) => {
|
|
584
|
+
if (typeof value === 'string') {
|
|
585
|
+
if (!value.startsWith('./'))
|
|
586
|
+
fail(
|
|
587
|
+
`Export ${subpath} must name a package-relative packed target: ${value}`,
|
|
588
|
+
);
|
|
589
|
+
const targets = packedTargets(value);
|
|
590
|
+
for (const target of targets) {
|
|
591
|
+
if (!isRuntimeSourceFile(target)) continue;
|
|
592
|
+
const marker = reachesSvelte(resolve(packageRoot, target));
|
|
593
|
+
if (!marker) continue;
|
|
594
|
+
const effective = scopes.find(
|
|
595
|
+
({ conditions }) =>
|
|
596
|
+
conditions.svelte !== undefined && conditions.svelte !== null,
|
|
597
|
+
);
|
|
598
|
+
if (!effective) {
|
|
599
|
+
fail(
|
|
600
|
+
`Export ${subpath} (${value}) reaches Svelte runtime via ${marker}; add an effective "svelte" condition with a packaged runtime target before fallback runtime conditions (types first)`,
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
const keys = Object.keys(effective.conditions);
|
|
604
|
+
const svelteIndex = keys.indexOf('svelte');
|
|
605
|
+
if (
|
|
606
|
+
(keys.includes('types') && keys[0] !== 'types') ||
|
|
607
|
+
keys.slice(0, svelteIndex).some((key) => key !== 'types')
|
|
608
|
+
) {
|
|
609
|
+
fail(
|
|
610
|
+
`Export ${subpath} (${value}) has unusable condition order; put types first, then svelte before import/default and other runtime conditions`,
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
// Svelte-aware bundlers may consume raw source while other consumers
|
|
614
|
+
// use a separate compiled entry. Presence, order and packaged targets
|
|
615
|
+
// are statically checkable; API equivalence needs consumer tests.
|
|
616
|
+
if (!validatedConditions.has(effective.conditions)) {
|
|
617
|
+
if (!validateSvelteTargets(effective.conditions.svelte, subpath))
|
|
618
|
+
fail(`Export ${subpath} has no effective packed svelte target`);
|
|
619
|
+
validatedConditions.add(effective.conditions);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
if (value === null) return;
|
|
625
|
+
if (Array.isArray(value)) {
|
|
626
|
+
for (const child of value) inspect(child, subpath, scopes);
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
if (!value || typeof value !== 'object')
|
|
630
|
+
fail(`Invalid export map for ${subpath}`);
|
|
631
|
+
for (const [condition, child] of Object.entries(value)) {
|
|
632
|
+
if (condition === 'types' || condition.startsWith('types@')) continue;
|
|
633
|
+
if (condition.startsWith('.')) {
|
|
634
|
+
if (!resourceExports.has(condition)) inspect(child, condition, []);
|
|
635
|
+
} else inspect(child, subpath, [{ conditions: value }, ...scopes]);
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
if (packageJson.exports !== undefined) inspect(packageJson.exports, '.');
|
|
639
|
+
}
|
|
640
|
+
|
|
415
641
|
function collectMissingTypeImports(packageRoot, typeEntryFiles) {
|
|
416
642
|
const missing = [];
|
|
417
643
|
const importPattern =
|
|
@@ -484,18 +710,9 @@ const packageArgument = args.find(
|
|
|
484
710
|
const packageDir = resolve(process.cwd(), packageArgument ?? '.');
|
|
485
711
|
const packageJsonPath = join(packageDir, 'package.json');
|
|
486
712
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
487
|
-
const typePaths = collectTypePaths(packageJson);
|
|
488
|
-
const runtimePaths = collectRuntimePaths(packageJson);
|
|
489
713
|
const npmConfigDryRunKey = 'npm_config_dry_run';
|
|
490
714
|
const npmConfigDryRunUpperKey = 'NPM_CONFIG_DRY_RUN';
|
|
491
715
|
|
|
492
|
-
if (typePaths.length === 0 && runtimePaths.length === 0) {
|
|
493
|
-
console.log(
|
|
494
|
-
`ℹ️ No exported pack verification paths declared for ${packageJson.name}`,
|
|
495
|
-
);
|
|
496
|
-
process.exit(0);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
716
|
const tempDir = mkdtempSync(join(tmpdir(), 'smrt-pack-'));
|
|
500
717
|
|
|
501
718
|
try {
|
|
@@ -537,6 +754,17 @@ try {
|
|
|
537
754
|
.filter(Boolean),
|
|
538
755
|
);
|
|
539
756
|
|
|
757
|
+
run('tar', ['-xf', tarballPath, '-C', tempDir]);
|
|
758
|
+
const packageRoot = join(tempDir, 'package');
|
|
759
|
+
const packedPackageJson = JSON.parse(
|
|
760
|
+
readFileSync(join(packageRoot, 'package.json'), 'utf8'),
|
|
761
|
+
);
|
|
762
|
+
const resourceExports = collectResourceExports(
|
|
763
|
+
packedPackageJson,
|
|
764
|
+
archiveEntries,
|
|
765
|
+
);
|
|
766
|
+
const typePaths = collectTypePaths(packedPackageJson);
|
|
767
|
+
const runtimePaths = collectRuntimePaths(packedPackageJson, resourceExports);
|
|
540
768
|
const missing = typePaths.filter(
|
|
541
769
|
(typePath) => !archiveHasPath(archiveEntries, typePath),
|
|
542
770
|
);
|
|
@@ -545,8 +773,12 @@ try {
|
|
|
545
773
|
(runtimePath) => !archiveHasPath(archiveEntries, runtimePath),
|
|
546
774
|
);
|
|
547
775
|
|
|
548
|
-
|
|
549
|
-
|
|
776
|
+
verifySvelteExportConditions(
|
|
777
|
+
packageRoot,
|
|
778
|
+
packedPackageJson,
|
|
779
|
+
archiveEntries,
|
|
780
|
+
resourceExports,
|
|
781
|
+
);
|
|
550
782
|
const runtimeEntryFiles = collectPackageEntryFiles(
|
|
551
783
|
packageRoot,
|
|
552
784
|
runtimePaths,
|
|
@@ -590,6 +822,7 @@ try {
|
|
|
590
822
|
`✅ Verified packed exports for ${packageJson.name}: ${[
|
|
591
823
|
...typePaths.map((typePath) => `types=${typePath}`),
|
|
592
824
|
...runtimePaths.map((runtimePath) => `runtime=${runtimePath}`),
|
|
825
|
+
...[...resourceExports].map((subpath) => `resource=${subpath}`),
|
|
593
826
|
].join(', ')}`,
|
|
594
827
|
);
|
|
595
828
|
} catch (error) {
|