File tree 5 files changed +48
-0
lines changed
5 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " wrangler " : minor
3
+ ---
4
+
5
+ Warn user when the last deployment was via the API
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import {
36
36
msw ,
37
37
mswSuccessDeployments ,
38
38
mswSuccessDeploymentScriptMetadata ,
39
+ mswSuccessDeploymentScriptAPI ,
39
40
} from "./helpers/msw" ;
40
41
import { FileReaderSync } from "./helpers/msw/read-file-sync" ;
41
42
import { runInTempDir } from "./helpers/run-in-tmp" ;
@@ -365,6 +366,22 @@ describe("deploy", () => {
365
366
} ) ;
366
367
} ) ;
367
368
369
+ describe ( "warnings" , ( ) => {
370
+ it ( "should warn user when worker was last deployed from api" , async ( ) => {
371
+ msw . use ( ...mswSuccessDeploymentScriptAPI ) ;
372
+ writeWranglerToml ( ) ;
373
+ writeWorkerSource ( ) ;
374
+ mockSubDomainRequest ( ) ;
375
+ mockUploadWorkerRequest ( ) ;
376
+
377
+ await runWrangler ( "deploy ./index" ) ;
378
+
379
+ expect ( std . warn ) . toMatch (
380
+ / Y o u a r e a b o u t t o p u b l i s h a W o r k e r s S e r v i c e t h a t w a s l a s t u p d a t e d v i a t h e s c r i p t A P I /
381
+ ) ;
382
+ } ) ;
383
+ } ) ;
384
+
368
385
describe ( "environments" , ( ) => {
369
386
it ( "should use legacy environments by default" , async ( ) => {
370
387
writeWranglerToml ( { env : { "some-env" : { } } } ) ;
Original file line number Diff line number Diff line change @@ -95,6 +95,23 @@ export const mswSuccessDeploymentScriptMetadata = [
95
95
) ,
96
96
] ;
97
97
98
+ export const mswSuccessDeploymentScriptAPI = [
99
+ rest . get (
100
+ "*/accounts/:accountId/workers/services/:scriptName" ,
101
+ ( _ , res , ctx ) => {
102
+ return res . once (
103
+ ctx . json (
104
+ createFetchResult ( {
105
+ default_environment : {
106
+ script : { last_deployed_from : "api" , tag : "MOCK-TAG" } ,
107
+ } ,
108
+ } )
109
+ )
110
+ ) ;
111
+ }
112
+ ) ,
113
+ ] ;
114
+
98
115
export const mswSuccessDeploymentDetails = [
99
116
rest . get (
100
117
"*/accounts/:accountId/workers/deployments/by-script/:scriptTag/detail/:deploymentId" ,
Original file line number Diff line number Diff line change 4
4
mswSuccessDeployments ,
5
5
mswSuccessDeploymentScriptMetadata ,
6
6
mswSuccessDeploymentDetails ,
7
+ mswSuccessDeploymentScriptAPI ,
7
8
} from "./handlers/deployments" ;
8
9
import { mswSuccessNamespacesHandlers } from "./handlers/namespaces" ;
9
10
import { mswSuccessOauthHandlers } from "./handlers/oauth" ;
@@ -49,4 +50,5 @@ export {
49
50
mswSuccessDeploymentDetails ,
50
51
mswAccessHandlers ,
51
52
mswSuccessDeploymentScriptMetadata ,
53
+ mswSuccessDeploymentScriptAPI ,
52
54
} ;
Original file line number Diff line number Diff line change @@ -283,6 +283,13 @@ export default async function deploy(props: Props): Promise<void> {
283
283
if ( ! ( await confirm ( "Would you like to continue?" ) ) ) {
284
284
return ;
285
285
}
286
+ } else if ( default_environment . script . last_deployed_from === "api" ) {
287
+ logger . warn (
288
+ `You are about to publish a Workers Service that was last updated via the script API.\nEdits that have been made via the script API will be overridden by your local code and config.`
289
+ ) ;
290
+ if ( ! ( await confirm ( "Would you like to continue?" ) ) ) {
291
+ return ;
292
+ }
286
293
}
287
294
} catch ( e ) {
288
295
// code: 10090, message: workers.api.error.service_not_found
You can’t perform that action at this time.
0 commit comments