screepers / screeps-typescript-starter

Starter kit for TypeScript-based Screeps AI codes.
https://screepers.gitbook.io/screeps-typescript-starter/
The Unlicense
441 stars 318 forks source link

Add option to not include git revision check #55

Closed staal closed 7 years ago

staal commented 7 years ago

Currently, npm run deploy errors out if you simply download the files, and run yarn, configure and attempt to upload to test. Nowhere is it indicated that you need to run git init, and commit files before npm run deploy will work.

Also, a command to run TSC without uploading (dry run) would be nice.

kotarou commented 7 years ago

Not sure about the git side, but to lint and compile without uploading, it should be fairly simple - using config/config.local.ts and pointing to a local (relative?) dir instead of the path of a local server. Probably should be split into a separate command.

bryanbecker commented 7 years ago

@staal did you download the repo instead of cloning it and start from there? What happens when you run npm run deploy in that situation that breaks?

Also, adding a build-but-don't-upload flag might be a nice idea, also to help work around the fact that watch-mode isn't friendly with bailing on errors.

You can also just copy the config.dev.ts, and rename it to something like config.prod.ts... and then just delete the upload part in config.dev.ts

staal commented 7 years ago

Yes I downloaded the zip file. The output of a fresh download, after running Yarn and setting up credentials is:

Staal@pc MINGW64 /f/screeps-typescript-starter-master
$ npm run deploy

> screeps-starter@2.0.0 deploy F:\screeps-typescript-starter-master
> webpack --colors --env.ENV=dev

F:\screeps-typescript-starter-master\node_modules\git-rev-sync\index.js:47
    throw new Error('[git-rev-sync] no git repository found');
          ^
Error: [git-rev-sync] no git repository found
    at _getGitDirectory (F:\screeps-typescript-starter-master\node_modules\git-rev-sync\index.js:47:11)
    at _getGitDirectory (F:\screeps-typescript-starter-master\node_modules\git-rev-sync\index.js:75:10)
    at _getGitDirectory (F:\screeps-typescript-starter-master\node_modules\git-rev-sync\index.js:75:10)
    at _getGitDirectory (F:\screeps-typescript-starter-master\node_modules\git-rev-sync\index.js:75:10)
    at _getGitDirectory (F:\screeps-typescript-starter-master\node_modules\git-rev-sync\index.js:75:10)
    at branch (F:\screeps-typescript-starter-master\node_modules\git-rev-sync\index.js:79:16)
    at long (F:\screeps-typescript-starter-master\node_modules\git-rev-sync\index.js:92:11)
    at Object.short (F:\screeps-typescript-starter-master\node_modules\git-rev-sync\index.js:118:10)
    at Object.init (F:\screeps-typescript-starter-master\config\config.common.ts:99:40)
    at webpackConfig (F:\screeps-typescript-starter-master\config\config.dev.ts:11:31)

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! screeps-starter@2.0.0 deploy: `webpack --colors --env.ENV=dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the screeps-starter@2.0.0 deploy script 'webpack --colors --env.ENV=dev'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the screeps-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack --colors --env.ENV=dev
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs screeps-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls screeps-starter
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     F:\screeps-typescript-starter-master\npm-debug.log

Running:

git init
git add *
git commit -m "initial"

It works with regular output:

Staal@pc MINGW64 /f/screeps-typescript-starter-master (master)
$ npm run deploy

> screeps-starter@2.0.0 deploy F:\screeps-typescript-starter-master
> webpack --colors --env.ENV=dev

clean-webpack-plugin: F:\screeps-typescript-starter-master\dist\dev\* has been removed.

[at-loader] Using typescript@2.3.4 from typescript and "tsconfig.json" from F:\screeps-typescript-starter-master\tsconfig.json.

[at-loader] Checking started in a separate process...

[at-loader] Ok, 0.363 sec.
Hash: 43c8ac63d173f90e1c7e
Version: webpack 2.6.1
Time: 3264ms
      Asset    Size  Chunks             Chunk Names
    main.js  121 kB       0  [emitted]  main
main.js.map  158 kB       0  [emitted]  main
   [0] ./~/source-map/lib/util.js 10.5 kB {0} [built]
   [1] ./src/config/config.ts 657 bytes {0} [built]
   [2] ./src/lib/logger/log.ts 5.53 kB {0} [built]
   [3] ./src/lib/logger/logLevels.ts 386 bytes {0} [built]
   [4] ./~/source-map/lib/array-set.js 2.76 kB {0} [built]
   [5] ./~/source-map/lib/base64-vlq.js 4.71 kB {0} [built]
   [6] ./~/source-map/lib/source-map-generator.js 13.4 kB {0} [built]
   [7] ./src/main.ts 1.03 kB {0} [built]
  [11] ./~/screeps-profiler/screeps-profiler.js 8.72 kB {0} [built]
  [13] ./~/source-map/lib/binary-search.js 4.25 kB {0} [built]
  [14] ./~/source-map/lib/mapping-list.js 2.34 kB {0} [built]
  [16] ./~/source-map/lib/source-map-consumer.js 38.4 kB {0} [built]
  [17] ./~/source-map/lib/source-node.js 13.5 kB {0} [built]
  [18] ./~/source-map/source-map.js 405 bytes {0} [optional] [built]
  [20] multi ./src/main.ts 28 bytes {0} [built]
    + 6 hidden modules

Probably should have split the other part into a separate issue. I have fixed it locally to add a "npm run build" command, which also temporarily fixes the other issue I posted, that build-fails still uploads.

bryanbecker commented 7 years ago

Ah, I got it! It's the git-rev-parse plugin causing the error. That's the one we use to allow the starter to upload based on the git branch name.

I'll see if there's a way to wrap it in an if check

resir014 commented 7 years ago

I'd probably suggest that we also add a vcs config on credentials.json which can be filled with any VCS systems, or left blank if they don't use any VCS st all, that way we can later add support for people who use SVN or Mercurial for whatever reason.

resir014 commented 7 years ago

Since this is the most commonly-asked issue on the #typescript channel, I'm currently exploring options to not include git revisions for people don't have a git repo. Please stand by.

resir014 commented 7 years ago

Fix is ready! 🎉