vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

Installation offline #1372

Open edarblanco opened 6 years ago

edarblanco commented 6 years ago

What problem does this feature solve?

Create applications disconnected from the internet, previously it was possible to download the templates (vue init webpack --offline) and then install their disconnected dependencies in the same way (yarn install --offline), like me many people in my country do not have a connection stable (constant) and high level (slow), so we handle a huge cache, but it is an alternative that allows us to continue developing very

What does the proposed API look like?

Could not be as it was before? vue create app --offline

nickbreen commented 4 years ago

The generic way to implement this is to allow specification of 'package manager args' along with --packageManager. E.g.

vue create --packageManager yarn --packageManagerArgs '--prefer-offline' app

This would also allow for a .yarnrc file to be specified.

nickbreen commented 4 years ago

Vue CLI will honour a .yarnrc file that's in the new project's directory.

This introduces are chicken-and-egg situation though if you're using a monorepo.

# setup a repo-wide yarnrc file to set prefer-offline mode
echo '--install.prefer-offline' >> .yarnrc
# pre-create the new Vue CLI project directory
mkdir app
# symlink .yarnrc into the project directory
ln -srt app .yarnrc
# create the project, but merge it with the existing directory
vue create --packageManager yarn --merge app
edarblanco commented 4 years ago

Thanks for the advice, now after trying I get an error that says Unknown option --packageManagerArgs

nickbreen commented 4 years ago

Sorry, there's no such argument. That message was a suggestion of how the yarn devs could help fix it.

Use the .yarnrc solution I posted.

nickbreen commented 4 years ago

Further issues...

@vue/lib/Creator.js, line 133

    const { latestMinor } = await getVersions()

and line 154

        ((/^@vue/.test(dep)) ? `~${latestMinor}` : `latest`)

are non-deterministic. This forces yarn to try and search for a version matching the ~ constraint. This fails with the yarn-offline-mirror.