vuejs / vue-cli

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

Importing unnamed project #3175

Open marcnewton opened 5 years ago

marcnewton commented 5 years ago

Version

3.2.1

Environment info

 System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz
  Binaries:
    Node: Not Found
    Yarn: Not Found
    npm: 6.5.0 - D:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 42.17134.1.0
  npmPackages:
    @vue/babel-preset-app:  3.2.0
    @vue/cli-overlay:  3.2.0
    @vue/cli-plugin-babel: ^3.2.0 => 3.2.0
    @vue/cli-service: ^3.2.0 => 3.2.0
    @vue/cli-shared-utils:  3.2.0
    @vue/component-compiler-utils:  2.3.1
    @vue/preload-webpack-plugin:  1.1.0
    @vue/web-component-wrapper:  1.2.0
    babel-helper-vue-jsx-merge-props:  2.0.3
    babel-plugin-transform-vue-jsx:  4.0.1
    vue: ^2.5.21 => 2.5.21
    vue-hot-reload-api:  2.3.1
    vue-loader:  15.4.2
    vue-router: ^3.0.2 => 3.0.2
    vue-style-loader: ^4.1.2 => 4.1.2
    vue-template-compiler: ^2.5.21 => 2.5.21
    vue-template-es2015-compiler:  1.6.0
    vuex: ^3.0.1 => 3.0.1
  npmGlobalPackages:
    @vue/cli: Not Found << Dont know why it says that, it is installed and running fine...

Steps to reproduce

Import a project containing a package.json with no "name" property.

{
    "private": true,
    "scripts": {
        "serve": "vue-cli-service serve",
        "build": "rm -rf public/{js,css,img} && vue-cli-service build --no-clean"
    },
    "devDependencies": {
        "@vue/cli-plugin-babel": "^3.2.0",
        "@vue/cli-service": "^3.2.0",
        "axios": "^0.18",
        "babel-core": "^6.26.3",
        "babel-jest": "^23.6.0",
        "file-loader": "^2.0.0",
        "lodash": "^4.17.11",
        "node-sass": "^4.11.0",
        "popper.js": "^1.14.6",
        "sass-loader": "^7.1.0",
        "vue": "^2.5.21",
        "vue-router": "^3.0.2",
        "vue-style-loader": "^4.1.2",
        "vue-template-compiler": "^2.5.21",
        "webpack": "^4.27.1",
        "vuex": "^3.0.1"
    }
}

What is expected?

Should default to string Undefined or Unnamed.

What is actually happening?

vue ui client blank screen behavior. ApolloError.js:37 Uncaught (in promise) Error: GraphQL error: Cannot return null for non-nullable field Project.name.

Adding missing "name" to package.json and forcing reload does not fix issue.

LinusBorg commented 5 years ago

Well, vue-cli 3 projects are always generated with a name, it's kind of required. We could enhance the error though.

marcnewton commented 5 years ago

Yes but, if you build your project by any other means or on top of say Laravel and forget to put the name because it is omitted in a laravel package file or say your a newbie and take it out by mistake, the vue cli becomes badly bricked.

The import tool needs to check what it is importing has a name set or it breaks it all but i feel something should be done to make sure the UI is not crippled by it.

Vue Project Manager wont list anything. TypeError: Cannot read property 'favorite' of null

marcnewton commented 5 years ago

Importing an unnamed project has caused this issue #2198 as I am now seeing this error:

An error occured vue-apollo.js:55 GraphQL error: Cannot return null for non-nullable field Project.name.

I checked in .vue-cli-ui/db.json and I can see:

    {
      "id": "8XUD7L3Iu",
      "path": "D:\\var\\www\\vhosts\\laravue-spa-sessions",
      "favorite": 0,
      "type": "vue",
      "openDate": 1545579060106
    },

As you can see the name is missing, the only way to get out of this catastrophic simple mistake is to know to wipe the database or know how to fix the entry..

This issue seems to permanently break vue cli ui.

Project lists breaks, Dashboard and Analyzer all get totally wreaked, Plugins and Dependencies don't fully render, you cant even switch to another project.

Fixing the bad entries in the database restores all functionality.

Akryum commented 5 years ago

The project import feature could sure get some love. I was thinking of auto-installing deps if node_modules is missing and we could add this to the list. 😸