Semantic-Org / Semantic-UI

Semantic is a UI component framework based around useful principles from natural language.
http://www.semantic-ui.com
MIT License
51.09k stars 4.95k forks source link

Incorrect format of file permission octal value in semantic.json #6684

Open ko2in opened 5 years ago

ko2in commented 5 years ago

When installed semantic-ui with express or custom installation method, and set the custom file permission, semantic-ui creates semantic.json and stores the octal number of file permission with quotes as string format.

{
  "base": "semantic/",
  "paths": {
    "source": {
      "config": "src/theme.config",
      "definitions": "src/definitions/",
      "site": "src/site/",
      "themes": "src/themes/"
    },
    "output": {
      "packaged": "dist/",
      "uncompressed": "dist/components/",
      "compressed": "dist/components/",
      "themes": "dist/themes/"
    },
    "clean": "dist/"
  },
  "permission": "644",
  "autoInstall": false,
  "rtl": false,
  "components": ["reset", "site", "button", "container", "divider", "flag", "header", "icon", "image", "input", "label", "list", "loader", "placeholder", "rail", "reveal", "segment", "step", "breadcrumb", "form", "grid", "menu", "message", "table", "ad", "card", "comment", "feed", "item", "statistic", "accordion", "checkbox", "dimmer", "dropdown", "embed", "modal", "nag", "popup", "progress", "rating", "search", "shape", "sidebar", "sticky", "tab", "transition", "api", "form", "state", "visibility"],
  "version": "2.4.2"
}

It makes the build process failed and thrown an error from gulp-chmod plugin when running gulp build.

[17:45:46] Using gulpfile ~/Desktop/semantic/semantic/gulpfile.js
[17:45:46] Starting 'build'...
Building Semantic
[17:45:46] Starting 'build-javascript'...
Building Javascript
[17:45:46] 'build-javascript' errored after 11 ms
[17:45:46] TypeError: Expected mode to be null/undefined/number/Object
    at module.exports (/home/koko/Desktop/semantic/node_modules/gulp-chmod/index.js:30:9)
    at Gulp.module.exports (/home/koko/Desktop/semantic/semantic/tasks/build/javascript.js:63:40)
    at module.exports (/home/koko/Desktop/semantic/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/home/koko/Desktop/semantic/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/home/koko/Desktop/semantic/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/home/koko/Desktop/semantic/node_modules/orchestrator/index.js:134:8)
    at runNextSet (/home/koko/Desktop/semantic/node_modules/run-sequence/index.js:124:15)
    at runSequence (/home/koko/Desktop/semantic/node_modules/run-sequence/index.js:136:2)
    at Gulp.module.exports (/home/koko/Desktop/semantic/semantic/tasks/build.js:49:3)
    at module.exports (/home/koko/Desktop/semantic/node_modules/orchestrator/lib/runTask.js:34:7)

Because, gulp chmod doesn't expect the permission as string format, but semantic task passes the permission as string which stores in semantic.json.

If I removed the quotes from permission property "permission": 644 in semantic.json and gulp build works as expected.

However, the permission shouldn't store with quote when creating semantic.json automatically in the installation process.

Steps to reproduce

Go to the project directory to install semantic-ui from terminal. Run command

npm install --save-dev semantic-ui

Choose express or custom method for setup.

? Set-up Semantic UI 
❯ Automatic (Use default locations and all components) 
  Express (Set components and output folder) 
  Custom (Customize all src/dist values)

Continue to set your project directory, and choose the components to install. Then choose "Yes" to set permissions on outputted files.

? Should we set permissions on outputted files? (Use arrow keys)
❯ No 
  Yes

Enter the octal number of your permission (eg., 644) and then continue to finish setup. Go to the directory that you've chosen to install semantic-ui in setup process. Run the command gulp build.

Expected Result

Build process success with gulp build and create all semantic-ui CSS and JS files in /dist directory.

Actual Result

Build process failed and errors occurred in console as described above.

Version

semantic-ui (2.4.2) gulp (3.9.1)

wind0204 commented 5 years ago

I've found a quick fix for this bug: wrap the number in a pair of double quotes. 644 -> "644"; and yes, I believe the builder should be flexible enough to understand numeric values as well as string values.