Vue-cli: Vue cli-plugin-typescript assumes project is Git based

Created on 20 Jun 2018  Â·  19Comments  Â·  Source: vuejs/vue-cli

Version

3.0.0-rc.3

Reproduction link

https://jsfiddle.net/0dnfLwhu/3/

Steps to reproduce

In an existing Vue project, that is not under git source control

  • vue add @vue/typescript

What is expected?

The plugin will support projects that are not using Git

What is actually happening?

✔ Successfully installed plugin: @vue/cli-plugin-typescript

? Use class-style component syntax? Yes
? Use Babel alongside TypeScript for auto-detected polyfills? Yes
? Use TSLint? Yes
? Pick lint features: Lint on save

🚀 Invoking generator for @vue/cli-plugin-typescript...
yarn install v1.7.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Saved lockfile.
Done in 9.63s.
📦 Installing additional dependencies...

Successfully invoked generator for plugin: @vue/cli-plugin-typescript
ERROR Error: Command failed: git ls-files --exclude-standard --modified --others
fatal: not a git repository (or any of the parent directories): .git

Error: Command failed: git ls-files --exclude-standard --modified --others
fatal: not a git repository (or any of the parent directories): .git

at Promise.all.then.arr (C:\Users\user\AppData\Local\Yarn\Data\global\node_modules\execa\index.js:236:11)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)

Windows 10
Yarn 1.7.0
NodeJS v9.5.0

bug ui

Most helpful comment

All 19 comments

@smarkwell running vue create xxx to create a new project, will always initialise that project with a git repository. So this is something that cannot be dealt with in cli-plugin-typescript, as it only instructs the existing plugin API to do something or the other.

@LinusBorg this is not at all related to typescript but to the way that vue-cli works. It simply assumes that one is always working with a git repository.

Git repo initialization can be disabled, so the typescript plugin should indeed work in this case.

@Akryum can you please provide us with a pointer into the documentation, or even an example?

just run vue create --help or read here: https://cli.vuejs.org/guide/creating-a-project.html#vue-create

@LinusBorg installing latest @vue/cli will leave us with [email protected], which does not support the --git option, but this is unrelated.

@LinusBorg

npm install -g @vue/cli
/Users/cklein/.nvm/versions/node/v8.11.1/bin/vue -> /Users/cklein/.nvm/versions/node/v8.11.1/lib/node_modules/@vue/cli/bin/vue.js

> [email protected] install /Users/cklein/.nvm/versions/node/v8.11.1/lib/node_modules/@vue/cli/node_modules/fsevents
> node install

[fsevents] Success: "/Users/cklein/.nvm/versions/node/v8.11.1/lib/node_modules/@vue/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> [email protected] postinstall /Users/cklein/.nvm/versions/node/v8.11.1/lib/node_modules/@vue/cli/node_modules/nodemon
> node bin/postinstall || exit 0

+ @vue/[email protected]
added 675 packages in 122.445s
raggamuffin:tmp cklein$ vue
vue              vue-cli-service
raggamuffin:tmp cklein$ vue create --git=false

  Usage: create [options] <app-name>

  create a new project powered by vue-cli-service

  Options:

    -p, --preset <presetName>       Skip prompts and use saved or remote preset
    -d, --default                   Skip prompts and use default preset
    -i, --inlinePreset <json>       Skip prompts and use inline JSON string as preset
    -m, --packageManager <command>  Use specified npm client when installing dependencies
    -r, --registry <url>            Use specified npm registry when installing dependencies (only for npm)
    -f, --force                     Overwrite target directory if it exists
    -c, --clone                     Use git clone when fetching remote preset
    -h, --help                      output usage information

  Unknown option --git.

raggamuffin:tmp cklein$ vue create --git=false foobar

  Usage: create [options] <app-name>

  create a new project powered by vue-cli-service

  Options:

    -p, --preset <presetName>       Skip prompts and use saved or remote preset
    -d, --default                   Skip prompts and use default preset
    -i, --inlinePreset <json>       Skip prompts and use inline JSON string as preset
    -m, --packageManager <command>  Use specified npm client when installing dependencies
    -r, --registry <url>            Use specified npm registry when installing dependencies (only for npm)
    -f, --force                     Overwrite target directory if it exists
    -c, --clone                     Use git clone when fetching remote preset
    -h, --help                      output usage information

  Unknown option --git.

raggamuffin:tmp cklein$ vue --version
3.0.0-beta.6

@silkentrance This is unrelated to the issue. You may have multiple versions installed (like one for npm and one for yarn). Please open another issue if you still can't properly install 3.0.0-rc.3.

@Akryum I have just removed both the yarn installed global version and the npm installed global version.
After reinstalling npm -g install @vue/cli, the vue command is no longer available, yet again, as already mentioned before, totally unrelated.

@Akryum

npm install -g @vue/cli
/Users/cklein/.nvm/versions/node/v8.11.1/bin/vue -> /Users/cklein/.nvm/versions/node/v8.11.1/lib/node_modules/@vue/cli/bin/vue.js
+ @vue/[email protected]
updated 1 package in 110.863s

@Akryum but after running vue from the specified above path I was able to create without a git repo.

In short: this is an issue with your local environment.

@LinusBorg @smarkwell as LinusBorg stated, this is an issue with your local environment. I just created a new project without the --git=false option, and it will not create a git repository. (unrelated but still an issue :grin:).

And then running vue add @vue/typescript will work just fine.

@Akryum @smarkwell @LinusBorg after having set up a new project, after having uninstalled all yarn/npm installed versions of @vue/cli and reinstalling from scratch, I was finally able to reproduce the error.

Turns out that this is related to packages/\@vue/cli-ui/apollo-server/connectors/git.js.

caused by

packages/@vue/cli-plugin-typescript/generator/index.js:        gitHooks: {
packages/@vue/cli-plugin-typescript/generator/index.js:          '*.ts': ['vue-cli-service lint', 'git add'],
packages/@vue/cli-plugin-typescript/generator/index.js:          '*.vue': ['vue-cli-service lint', 'git add']

other plugins also suffer from that.

Thanks for looking into this!

@LinusBorg in packages/@vue/cli/lib/Creator.js it will first try to find out whether there is a git repository available, perhaps this might help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JIANGYUJING1995 picture JIANGYUJING1995  Â·  3Comments

csakis picture csakis  Â·  3Comments

PrimozRome picture PrimozRome  Â·  3Comments

eladcandroid picture eladcandroid  Â·  3Comments

b-zee picture b-zee  Â·  3Comments