@pithy-sh/core 0.6.1 → 0.6.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/naming/provisionScope.d.ts +33 -9
- package/dist/naming/provisionScope.d.ts.map +1 -1
- package/dist/naming/provisionScope.js +26 -8
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +1 -1
- package/src/naming/provisionScope.ts +34 -10
- package/src/version.generated.ts +1 -1
|
@@ -118,8 +118,14 @@ export interface ProvisionScope {
|
|
|
118
118
|
* is created, judged to be the project's, kept out of the teardown record, and orphaned.
|
|
119
119
|
*/
|
|
120
120
|
readonly honorsGlobal: boolean;
|
|
121
|
-
/**
|
|
122
|
-
|
|
121
|
+
/**
|
|
122
|
+
* The script name a Worker deploys under in this scope.
|
|
123
|
+
*
|
|
124
|
+
* `declared` is the name that scope's stanza already carries, when it carries one. A scope may honor it
|
|
125
|
+
* or compose its own; see {@link environmentScope} and {@link featureScope}, which answer differently
|
|
126
|
+
* and say why. Passing it is how a caller asks the scope rather than deciding for itself.
|
|
127
|
+
*/
|
|
128
|
+
worker(worker: string, declared?: string): string;
|
|
123
129
|
/**
|
|
124
130
|
* This scope's CF Secrets Store entry name for a declared secret.
|
|
125
131
|
*
|
|
@@ -165,13 +171,25 @@ export declare function bindingResourceName(project: string, binding: string, ki
|
|
|
165
171
|
* every name below, so an illegal one must fail before anything is created rather than at the fourth
|
|
166
172
|
* getter that happened to use it.
|
|
167
173
|
*
|
|
168
|
-
* **A
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
174
|
+
* **A declared name wins; the fallback is wrangler's own, `<script>-<env>`.**
|
|
175
|
+
*
|
|
176
|
+
* This reverses the rule that stood here until #580, and the reversal is worth reading rather than
|
|
177
|
+
* assuming. The old rule *recomputed* `<script>-<env>` on every provision and wrote it over whatever the
|
|
178
|
+
* stanza said, on the argument that wrangler has always appended the environment to the top-level `name`,
|
|
179
|
+
* so every project that ever deployed is already at that address.
|
|
180
|
+
*
|
|
181
|
+
* That argument is still true about the **fallback**, and the fallback is unchanged: a stanza that names
|
|
182
|
+
* nothing gets `<script>-<env>` and every existing adopter deploys exactly where they always did. What was
|
|
183
|
+
* wrong was recomputing over a name somebody wrote down. Since #580 the starter template writes one —
|
|
184
|
+
* `<project>-<env>-<worker>`, the shape every other resource here takes — so recompute would have made the
|
|
185
|
+
* template's stamp pointless, and worse: it would have silently renamed the Worker of every project that
|
|
186
|
+
* had taken the new shape, on their next `pithy provision`. A Worker script is a `refuse`-policy namespace
|
|
187
|
+
* precisely because renaming one orphans the deployment, its routes, and every `service` binding pointing
|
|
188
|
+
* at it. Doing that as a side effect of provisioning is the failure the old rule was written to prevent,
|
|
189
|
+
* arriving from the other direction.
|
|
190
|
+
*
|
|
191
|
+
* So the name is read, not composed, when the file already holds one — and written out when it does not,
|
|
192
|
+
* so a service binding and a deploy still agree on one string that is in the file.
|
|
175
193
|
*/
|
|
176
194
|
export declare function environmentScope(project: string, environment: string): ProvisionScope;
|
|
177
195
|
/**
|
|
@@ -193,6 +211,12 @@ export declare function environmentScope(project: string, environment: string):
|
|
|
193
211
|
* `resource` is ignored for the same reason it is moot: a feature's `<thing>` segment is the binding plus
|
|
194
212
|
* the kind, and the whole name is recomputed on teardown rather than looked up, so nothing outside the
|
|
195
213
|
* feature reads the string.
|
|
214
|
+
*
|
|
215
|
+
* **And a declared Worker name is ignored here too — the other half of the #580 asymmetry.** A declared
|
|
216
|
+
* environment's script name is the adopter's, written in a tracked file, and provisioning reads it. A
|
|
217
|
+
* feature's is the kit's: it is composed from the branch, written into a generated config nobody commits,
|
|
218
|
+
* and **recomputed on teardown**. Honoring a declared one would leave `pithy feature destroy` computing a
|
|
219
|
+
* name the deployment does not answer to, which is a Worker nothing deletes.
|
|
196
220
|
*/
|
|
197
221
|
export declare function featureScope(identity: FeatureIdentity): ProvisionScope;
|
|
198
222
|
//# sourceMappingURL=provisionScope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisionScope.d.ts","sourceRoot":"","sources":["../../src/naming/provisionScope.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAIzB,MAAM,WAAW,CAAC;AAGnB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,QAAQ,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CAC1B;AAED,uFAAuF;AACvF,MAAM,WAAW,cAAc;IAC7B,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC;IACpF;;;;;;;;;OASG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B
|
|
1
|
+
{"version":3,"file":"provisionScope.d.ts","sourceRoot":"","sources":["../../src/naming/provisionScope.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAIzB,MAAM,WAAW,CAAC;AAGnB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;GAMG;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AAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAChC,MAAM,CAAC;AAsBV;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,CAerF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,cAAc,CAatE"}
|
|
@@ -38,13 +38,25 @@ function bindingResourceName(project, binding, kind, naming, scoped) {
|
|
|
38
38
|
* every name below, so an illegal one must fail before anything is created rather than at the fourth
|
|
39
39
|
* getter that happened to use it.
|
|
40
40
|
*
|
|
41
|
-
* **A
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
41
|
+
* **A declared name wins; the fallback is wrangler's own, `<script>-<env>`.**
|
|
42
|
+
*
|
|
43
|
+
* This reverses the rule that stood here until #580, and the reversal is worth reading rather than
|
|
44
|
+
* assuming. The old rule *recomputed* `<script>-<env>` on every provision and wrote it over whatever the
|
|
45
|
+
* stanza said, on the argument that wrangler has always appended the environment to the top-level `name`,
|
|
46
|
+
* so every project that ever deployed is already at that address.
|
|
47
|
+
*
|
|
48
|
+
* That argument is still true about the **fallback**, and the fallback is unchanged: a stanza that names
|
|
49
|
+
* nothing gets `<script>-<env>` and every existing adopter deploys exactly where they always did. What was
|
|
50
|
+
* wrong was recomputing over a name somebody wrote down. Since #580 the starter template writes one —
|
|
51
|
+
* `<project>-<env>-<worker>`, the shape every other resource here takes — so recompute would have made the
|
|
52
|
+
* template's stamp pointless, and worse: it would have silently renamed the Worker of every project that
|
|
53
|
+
* had taken the new shape, on their next `pithy provision`. A Worker script is a `refuse`-policy namespace
|
|
54
|
+
* precisely because renaming one orphans the deployment, its routes, and every `service` binding pointing
|
|
55
|
+
* at it. Doing that as a side effect of provisioning is the failure the old rule was written to prevent,
|
|
56
|
+
* arriving from the other direction.
|
|
57
|
+
*
|
|
58
|
+
* So the name is read, not composed, when the file already holds one — and written out when it does not,
|
|
59
|
+
* so a service binding and a deploy still agree on one string that is in the file.
|
|
48
60
|
*/
|
|
49
61
|
function environmentScope(project, environment) {
|
|
50
62
|
assertValidEnvironment(environment);
|
|
@@ -54,7 +66,7 @@ function environmentScope(project, environment) {
|
|
|
54
66
|
source: true,
|
|
55
67
|
honorsGlobal: true,
|
|
56
68
|
resource: (binding, kind, naming) => bindingResourceName(project, binding, kind, naming, (thing) => names[KIND_NAMER[kind]](thing)),
|
|
57
|
-
worker: (worker) => `${worker}-${environment}`,
|
|
69
|
+
worker: (worker, declared) => declared ?? `${worker}-${environment}`,
|
|
58
70
|
secretEntry: (secret, secretScope) => secretEntryName(project, secret, secretScope, () => names.secretEntry(secret))
|
|
59
71
|
};
|
|
60
72
|
}
|
|
@@ -77,6 +89,12 @@ function environmentScope(project, environment) {
|
|
|
77
89
|
* `resource` is ignored for the same reason it is moot: a feature's `<thing>` segment is the binding plus
|
|
78
90
|
* the kind, and the whole name is recomputed on teardown rather than looked up, so nothing outside the
|
|
79
91
|
* feature reads the string.
|
|
92
|
+
*
|
|
93
|
+
* **And a declared Worker name is ignored here too — the other half of the #580 asymmetry.** A declared
|
|
94
|
+
* environment's script name is the adopter's, written in a tracked file, and provisioning reads it. A
|
|
95
|
+
* feature's is the kit's: it is composed from the branch, written into a generated config nobody commits,
|
|
96
|
+
* and **recomputed on teardown**. Honoring a declared one would leave `pithy feature destroy` computing a
|
|
97
|
+
* name the deployment does not answer to, which is a Worker nothing deletes.
|
|
80
98
|
*/
|
|
81
99
|
function featureScope(identity) {
|
|
82
100
|
return {
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
/** This package's npm name — the join key against a release feed. */
|
|
4
4
|
export declare const PACKAGE_NAME = "@pithy-sh/core";
|
|
5
5
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
6
|
-
export declare const PACKAGE_VERSION = "0.6.
|
|
6
|
+
export declare const PACKAGE_VERSION = "0.6.2";
|
|
7
7
|
//# sourceMappingURL=version.generated.d.ts.map
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
/** This package's npm name — the join key against a release feed. */
|
|
5
5
|
const PACKAGE_NAME = "@pithy-sh/core";
|
|
6
6
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
7
|
-
const PACKAGE_VERSION = "0.6.
|
|
7
|
+
const PACKAGE_VERSION = "0.6.2";
|
|
8
8
|
//#endregion
|
|
9
9
|
export { PACKAGE_NAME, PACKAGE_VERSION };
|
package/package.json
CHANGED
|
@@ -133,8 +133,14 @@ export interface ProvisionScope {
|
|
|
133
133
|
* is created, judged to be the project's, kept out of the teardown record, and orphaned.
|
|
134
134
|
*/
|
|
135
135
|
readonly honorsGlobal: boolean;
|
|
136
|
-
/**
|
|
137
|
-
|
|
136
|
+
/**
|
|
137
|
+
* The script name a Worker deploys under in this scope.
|
|
138
|
+
*
|
|
139
|
+
* `declared` is the name that scope's stanza already carries, when it carries one. A scope may honor it
|
|
140
|
+
* or compose its own; see {@link environmentScope} and {@link featureScope}, which answer differently
|
|
141
|
+
* and say why. Passing it is how a caller asks the scope rather than deciding for itself.
|
|
142
|
+
*/
|
|
143
|
+
worker(worker: string, declared?: string): string;
|
|
138
144
|
/**
|
|
139
145
|
* This scope's CF Secrets Store entry name for a declared secret.
|
|
140
146
|
*
|
|
@@ -228,13 +234,25 @@ export function bindingResourceName(
|
|
|
228
234
|
* every name below, so an illegal one must fail before anything is created rather than at the fourth
|
|
229
235
|
* getter that happened to use it.
|
|
230
236
|
*
|
|
231
|
-
* **A
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
237
|
+
* **A declared name wins; the fallback is wrangler's own, `<script>-<env>`.**
|
|
238
|
+
*
|
|
239
|
+
* This reverses the rule that stood here until #580, and the reversal is worth reading rather than
|
|
240
|
+
* assuming. The old rule *recomputed* `<script>-<env>` on every provision and wrote it over whatever the
|
|
241
|
+
* stanza said, on the argument that wrangler has always appended the environment to the top-level `name`,
|
|
242
|
+
* so every project that ever deployed is already at that address.
|
|
243
|
+
*
|
|
244
|
+
* That argument is still true about the **fallback**, and the fallback is unchanged: a stanza that names
|
|
245
|
+
* nothing gets `<script>-<env>` and every existing adopter deploys exactly where they always did. What was
|
|
246
|
+
* wrong was recomputing over a name somebody wrote down. Since #580 the starter template writes one —
|
|
247
|
+
* `<project>-<env>-<worker>`, the shape every other resource here takes — so recompute would have made the
|
|
248
|
+
* template's stamp pointless, and worse: it would have silently renamed the Worker of every project that
|
|
249
|
+
* had taken the new shape, on their next `pithy provision`. A Worker script is a `refuse`-policy namespace
|
|
250
|
+
* precisely because renaming one orphans the deployment, its routes, and every `service` binding pointing
|
|
251
|
+
* at it. Doing that as a side effect of provisioning is the failure the old rule was written to prevent,
|
|
252
|
+
* arriving from the other direction.
|
|
253
|
+
*
|
|
254
|
+
* So the name is read, not composed, when the file already holds one — and written out when it does not,
|
|
255
|
+
* so a service binding and a deploy still agree on one string that is in the file.
|
|
238
256
|
*/
|
|
239
257
|
export function environmentScope(project: string, environment: string): ProvisionScope {
|
|
240
258
|
assertValidEnvironment(environment);
|
|
@@ -247,7 +265,7 @@ export function environmentScope(project: string, environment: string): Provisio
|
|
|
247
265
|
honorsGlobal: true,
|
|
248
266
|
resource: (binding, kind, naming) =>
|
|
249
267
|
bindingResourceName(project, binding, kind, naming, (thing) => names[KIND_NAMER[kind]](thing)),
|
|
250
|
-
worker: (worker) => `${worker}-${environment}`,
|
|
268
|
+
worker: (worker, declared) => declared ?? `${worker}-${environment}`,
|
|
251
269
|
secretEntry: (secret, secretScope) =>
|
|
252
270
|
secretEntryName(project, secret, secretScope, () => names.secretEntry(secret)),
|
|
253
271
|
};
|
|
@@ -272,6 +290,12 @@ export function environmentScope(project: string, environment: string): Provisio
|
|
|
272
290
|
* `resource` is ignored for the same reason it is moot: a feature's `<thing>` segment is the binding plus
|
|
273
291
|
* the kind, and the whole name is recomputed on teardown rather than looked up, so nothing outside the
|
|
274
292
|
* feature reads the string.
|
|
293
|
+
*
|
|
294
|
+
* **And a declared Worker name is ignored here too — the other half of the #580 asymmetry.** A declared
|
|
295
|
+
* environment's script name is the adopter's, written in a tracked file, and provisioning reads it. A
|
|
296
|
+
* feature's is the kit's: it is composed from the branch, written into a generated config nobody commits,
|
|
297
|
+
* and **recomputed on teardown**. Honoring a declared one would leave `pithy feature destroy` computing a
|
|
298
|
+
* name the deployment does not answer to, which is a Worker nothing deletes.
|
|
275
299
|
*/
|
|
276
300
|
export function featureScope(identity: FeatureIdentity): ProvisionScope {
|
|
277
301
|
return {
|
package/src/version.generated.ts
CHANGED