Skip to content

Commit 782245a

Browse files
committed
Fix vue cli downloading
1 parent b012889 commit 782245a

File tree

1 file changed

+27
-8
lines changed
  • packages/app/src/app/store/providers/Utils/create-zip

1 file changed

+27
-8
lines changed

packages/app/src/app/store/providers/Utils/create-zip/index.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ export async function createZip(
194194
) {
195195
const zip = new JSZip();
196196

197+
const fullPromise = () =>
198+
import(/* webpackChunkName: 'full-zip' */ './full').then(generator =>
199+
generator.default(zip, sandbox, modules, directories, downloadBlobs)
200+
);
201+
197202
let promise = null;
198203

199204
if (
@@ -203,10 +208,7 @@ export async function createZip(
203208
) {
204209
// This is a full project, with all files already in there. We need to create
205210
// a zip by just adding all existing files to it (downloading binaries too).
206-
promise = import(/* webpackChunkName: 'full-zip' */ './full').then(
207-
generator =>
208-
generator.default(zip, sandbox, modules, directories, downloadBlobs)
209-
);
211+
promise = fullPromise();
210212
} else if (sandbox.template === react.name) {
211213
promise = import(/* webpackChunkName: 'create-react-app-zip' */ './create-react-app').then(
212214
generator =>
@@ -218,10 +220,27 @@ export async function createZip(
218220
generator.default(zip, sandbox, modules, directories, downloadBlobs)
219221
);
220222
} else if (sandbox.template === vue.name) {
221-
promise = import(/* webpackChunkName: 'vue-zip' */ './vue-cli').then(
222-
generator =>
223-
generator.default(zip, sandbox, modules, directories, downloadBlobs)
224-
);
223+
try {
224+
const packageJSONModule = sandbox.modules.find(
225+
m => m.directoryShortid == null && m.title === 'package.json'
226+
);
227+
228+
const pkgJSON = JSON.parse(packageJSONModule.code);
229+
if (
230+
pkgJSON.devDependencies &&
231+
pkgJSON.devDependencies['@vue/cli-service']
232+
) {
233+
// For the new vue cli we want to use the full promise
234+
promise = fullPromise();
235+
} else {
236+
promise = import(/* webpackChunkName: 'vue-zip' */ './vue-cli').then(
237+
generator =>
238+
generator.default(zip, sandbox, modules, directories, downloadBlobs)
239+
);
240+
}
241+
} catch (e) {
242+
promise = fullPromise();
243+
}
225244
} else if (sandbox.template === preact.name) {
226245
promise = import(/* webpackChunkName: 'preact-zip' */ './preact-cli').then(
227246
generator =>

0 commit comments

Comments
 (0)