You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interactively handle `wrangler deploy`s that are probably assets-only, where there is no config file and flags are incorrect or missing.
6
+
7
+
For example:
8
+
9
+
`npx wrangler deploy ./public` will now ask if you meant to deploy an folder of assets only, ask for a name, set the compat date and then ask to write your choices out to `wrangler.json` for subsequent deployments.
10
+
11
+
`npx wrangler deploy --assets=./public` will now ask for a name, set the compat date and then ask to write your choices out to `wrangler.json` for subsequent deployments.
12
+
13
+
In non-interactive contexts, we will error as we currently do.
text: "It looks like you are trying to deploy a directory of static assets only. Is this correct?",
2755
+
result: true,
2756
+
});
2757
+
mockPrompt({
2758
+
text: "What do you want to name your project?",
2759
+
options: {defaultValue: "my-site"},
2760
+
result: "test-name",
2761
+
});
2762
+
mockConfirm({
2763
+
text: "Do you want Wrangler to write a wrangler.json config file to store this configuration?\nThis will allow you to simply run `wrangler deploy` on future deployments.",
2764
+
result: true,
2765
+
});
2766
+
2767
+
constbodies: AssetManifest[]=[];
2768
+
awaitmockAUSRequest(bodies);
2769
+
2770
+
awaitrunWrangler("deploy ./assets");
2771
+
expect(bodies.length).toBe(1);
2772
+
expect(bodies[0]).toEqual({
2773
+
manifest: {
2774
+
"/index.html": {
2775
+
hash: "8308ce789f3d08668ce87176838d59d0",
2776
+
size: 17,
2777
+
},
2778
+
},
2779
+
});
2780
+
expect(fs.readFileSync("wrangler.json","utf-8"))
2781
+
.toMatchInlineSnapshot(`
2782
+
"{
2783
+
\\"name\\": \\"test-name\\",
2784
+
\\"compatibility_date\\": \\"2024-01-01\\",
2785
+
\\"assets\\": {
2786
+
\\"directory\\": \\"./assets\\"
2787
+
}
2788
+
}"
2789
+
`);
2790
+
expect(std.out).toMatchInlineSnapshot(`
2791
+
"
2792
+
2793
+
2794
+
No compatibility date found Defaulting to today: 2024-01-01
2795
+
2796
+
Wrote
2797
+
{
2798
+
\\"name\\": \\"test-name\\",
2799
+
\\"compatibility_date\\": \\"2024-01-01\\",
2800
+
\\"assets\\": {
2801
+
\\"directory\\": \\"./assets\\"
2802
+
}
2803
+
}
2804
+
to <cwd>/wrangler.json.
2805
+
Please run wrangler deploy instead of wrangler deploy ./assets next time. Wrangler will automatically use the configuration saved to wrangler.json.
2806
+
2807
+
Total Upload: xx KiB / gzip: xx KiB
2808
+
Worker Startup Time: 100 ms
2809
+
Uploaded test-name (TIMINGS)
2810
+
Deployed test-name triggers (TIMINGS)
2811
+
https://test-name.test-sub-domain.workers.dev
2812
+
Current Version ID: Galaxy-Class"
2813
+
`);
2814
+
});
2815
+
it("should handle `wrangler deploy --assets` without name or compat date",async()=>{
2816
+
// if the user has used --assets flag and args.script is not set, we just need to prompt for the name and add compat date
2817
+
mockPrompt({
2818
+
text: "What do you want to name your project?",
2819
+
options: {defaultValue: "my-site"},
2820
+
result: "test-name",
2821
+
});
2822
+
mockConfirm({
2823
+
text: "Do you want Wrangler to write a wrangler.json config file to store this configuration?\nThis will allow you to simply run `wrangler deploy` on future deployments.",
2824
+
result: true,
2825
+
});
2826
+
2827
+
constbodies: AssetManifest[]=[];
2828
+
awaitmockAUSRequest(bodies);
2829
+
2830
+
awaitrunWrangler("deploy --assets ./assets");
2831
+
expect(bodies.length).toBe(1);
2832
+
expect(bodies[0]).toEqual({
2833
+
manifest: {
2834
+
"/index.html": {
2835
+
hash: "8308ce789f3d08668ce87176838d59d0",
2836
+
size: 17,
2837
+
},
2838
+
},
2839
+
});
2840
+
expect(fs.readFileSync("wrangler.json","utf-8"))
2841
+
.toMatchInlineSnapshot(`
2842
+
"{
2843
+
\\"name\\": \\"test-name\\",
2844
+
\\"compatibility_date\\": \\"2024-01-01\\",
2845
+
\\"assets\\": {
2846
+
\\"directory\\": \\"./assets\\"
2847
+
}
2848
+
}"
2849
+
`);
2850
+
expect(std.out).toMatchInlineSnapshot(`
2851
+
"
2852
+
2853
+
No compatibility date found Defaulting to today: 2024-01-01
2854
+
2855
+
Wrote
2856
+
{
2857
+
\\"name\\": \\"test-name\\",
2858
+
\\"compatibility_date\\": \\"2024-01-01\\",
2859
+
\\"assets\\": {
2860
+
\\"directory\\": \\"./assets\\"
2861
+
}
2862
+
}
2863
+
to <cwd>/wrangler.json.
2864
+
Please run wrangler deploy instead of wrangler deploy ./assets next time. Wrangler will automatically use the configuration saved to wrangler.json.
`${chalk.bold("No compatibility date found")} Defaulting to today:`,
441
+
compatibilityDate
442
+
);
443
+
logger.log("");
444
+
}
445
+
446
+
// Ask if user wants to write config file
447
+
constwriteConfig=awaitconfirm(
448
+
`Do you want Wrangler to write a wrangler.json config file to store this configuration?\n${chalk.dim("This will allow you to simply run `wrangler deploy` on future deployments.")}`
logger.log(`Wrote \n${jsonString}\n to ${chalk.bold(configPath)}.`);
464
+
logger.log(
465
+
`Please run ${chalk.bold("wrangler deploy")} instead of ${chalk.bold(`wrangler deploy ${args.assets}`)} next time. Wrangler will automatically use the configuration saved to wrangler.json.`
0 commit comments