我如何在我的 gulpfile 上添加构建任务?

How can i add a Build Task on my gulpfile?

我正在尝试安装名为 "BOSS" 的项目。

这是我尝试 运行 bin/buildout -c frontend.cfg 时得到的结果。 您可以在此处查看整个安装步骤。

<USER>@ubuntu:/opt/boss$ sudo bin/buildout -c frontend.cfg
Installing frontend-admin.
npm WARN package.json boss-admin@1.0.0 No description
npm WARN package.json boss-admin@1.0.0 No README data
npm WARN package.json angular-perfect-scrollbar@0.0.5 No repository field.
npm WARN package.json eslint-plugin-class-property@0.0.3 No repository field.
npm http GET https://registry.npmjs.org/bower
npm http 304 https://registry.npmjs.org/bower
bower@1.7.9 node_modules/bower
npm WARN package.json boss-admin@1.0.0 No description
npm WARN package.json boss-admin@1.0.0 No README data
npm WARN package.json angular-perfect-scrollbar@0.0.5 No repository field.
npm WARN package.json eslint-plugin-class-property@0.0.3 No repository field.
npm http GET https://registry.npmjs.org/bower/1.5.2
npm http 304 https://registry.npmjs.org/bower/1.5.2
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/archy/1.0.0
npm http GET https://registry.npmjs.org/bower-config
npm http GET https://registry.npmjs.org/bower-endpoint-parser
npm http GET https://registry.npmjs.org/bower-logger
npm http GET https://registry.npmjs.org/bower-json
npm http GET https://registry.npmjs.org/bower-registry-client
npm http GET https://registry.npmjs.org/cardinal/0.4.4
npm http GET https://registry.npmjs.org/chalk
npm http GET https://registry.npmjs.org/configstore
npm http GET https://registry.npmjs.org/decompress-zip
npm http GET https://registry.npmjs.org/chmodr/0.1.0
npm http GET https://registry.npmjs.org/fstream
npm http GET https://registry.npmjs.org/fstream-ignore
npm http GET https://registry.npmjs.org/github
npm http GET https://registry.npmjs.org/deep-sort-object
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/handlebars
npm http GET https://registry.npmjs.org/is-root
npm http GET https://registry.npmjs.org/inquirer/0.8.0
npm http GET https://registry.npmjs.org/insight
npm http GET https://registry.npmjs.org/junk
npm http GET https://registry.npmjs.org/mout
npm http GET https://registry.npmjs.org/lockfile
npm http GET https://registry.npmjs.org/lru-cache

------------ 剪切------------

npm http 304 https://registry.npmjs.org/amdefine
npm http GET https://registry.npmjs.org/end-of-stream/1.0.0
npm http GET https://registry.npmjs.org/stream-shift
npm http GET https://registry.npmjs.org/es6-iterator
npm http GET https://registry.npmjs.org/es6-symbol
npm http 304 https://registry.npmjs.org/es6-symbol
npm http 304 https://registry.npmjs.org/es6-iterator
npm http 304 https://registry.npmjs.org/es6-iterator
npm http 304 https://registry.npmjs.org/es6-symbol
npm http 304 https://registry.npmjs.org/pinkie-promise
npm http 304 https://registry.npmjs.org/stream-shift
npm http GET https://registry.npmjs.org/pinkie
npm http 304 https://registry.npmjs.org/end-of-stream/1.0.0
npm http GET https://registry.npmjs.org/once
npm http 304 https://registry.npmjs.org/pinkie
npm http 304 https://registry.npmjs.org/once
bower@1.5.2 node_modules/bower
├── is-root@1.0.0
├── abbrev@1.0.9
├── junk@1.0.3
├── stringify-object@1.0.1
├── user-home@1.1.1
├── chmodr@0.1.0
├── opn@1.0.2
├── archy@1.0.0
├── bower-logger@0.2.2
├── bower-endpoint-parser@0.2.2
├── nopt@3.0.6
├── lru-cache@2.7.3
├── retry@0.6.1
├── lockfile@1.0.2
├── tmp@0.0.24
├── q@1.4.1
├── semver@2.3.2
├── p-throttler@0.1.1 (q@0.9.7)
├── which@1.2.11 (isexe@1.1.2)
├── deep-sort-object@0.1.1 (mout@0.9.1)
├── mout@0.11.1
├── graceful-fs@3.0.11 (natives@1.1.0)
├── request-progress@0.3.1 (throttleit@0.0.2)
├── shell-quote@1.6.1 (array-filter@0.0.1, array-reduce@0.0.0, array-map@0.0.0, jsonify@0.0.0)
├── bower-json@0.4.0 (intersect@0.0.3, deep-extend@0.2.11, graceful-fs@2.0.3)
├── mkdirp@0.5.0 (minimist@0.0.8)
├── fstream@1.0.10 (inherits@2.0.3, graceful-fs@4.1.6)
├── github@0.2.4 (mime@1.3.4)
├── chalk@1.1.3 (escape-string-regexp@1.0.5, supports-color@2.0.0, ansi-styles@2.2.1, has-ansi@2.0.0, strip-ansi@3.0.1)
├── promptly@0.2.0 (read@1.0.7)
├── bower-config@0.6.1 (osenv@0.0.3, graceful-fs@2.0.3, mout@0.9.1, optimist@0.6.1)
├── cardinal@0.4.4 (ansicolors@0.2.1, redeyed@0.4.4)
├── configstore@0.3.2 (object-assign@2.1.1, xdg-basedir@1.0.1, uuid@2.0.3, osenv@0.1.3, js-yaml@3.6.1)
├── fstream-ignore@1.0.5 (inherits@2.0.3, minimatch@3.0.3)
├── rimraf@2.5.4 (glob@7.1.0)
├── glob@4.5.3 (inherits@2.0.3, inflight@1.0.5, once@1.4.0, minimatch@2.0.10)
├── insight@0.5.3 (object-assign@2.1.1, async@0.9.2, tough-cookie@0.12.1, lodash.debounce@3.1.1, os-name@1.0.3)
├── request@2.53.0 (tunnel-agent@0.4.3, caseless@0.9.0, forever-agent@0.5.2, aws-sign2@0.5.0, stringstream@0.0.5, oauth-sign@0.6.0, isstream@0.1.2, json-stringify-safe@5.0.1, node-uuid@1.4.7, qs@2.3.3, form-data@0.2.0, tough-cookie@2.3.1, bl@0.9.5, combined-stream@0.0.7, mime-types@2.0.14, http-signature@0.10.1, hawk@2.3.1)
├── decompress-zip@0.1.0 (mkpath@0.1.0, touch@0.0.3, readable-stream@1.1.14, binary@0.3.0)
├── tar-fs@1.13.2 (pump@1.0.1, tar-stream@1.5.2)
├── bower-registry-client@0.3.0 (graceful-fs@2.0.3, request-replay@0.2.0, rimraf@2.2.8, lru-cache@2.3.1, async@0.2.10, mkdirp@0.3.5, request@2.51.0)
├── handlebars@2.0.0 (optimist@0.3.7, uglify-js@2.3.6)
├── inquirer@0.8.0 (ansi-regex@1.1.1, mute-stream@0.0.4, through@2.3.8, figures@1.7.0, readline2@0.1.1, chalk@0.5.1, lodash@2.4.2, rx@2.5.3, cli-color@0.3.3)
└── update-notifier@0.3.2 (is-npm@1.0.0, semver-diff@2.1.0, string-length@1.0.1, latest-version@1.0.1)
[20:47:43] Working directory changed to /opt/boss/frontend/admin
[20:47:43] Using gulpfile /opt/boss/frontend/admin/gulpfile.js
[20:47:43] Task 'build' is not in your gulpfile
[20:47:43] Please check the documentation for proper gulpfile formatting
While:
  Installing frontend-admin.

An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
  File "/opt/boss/.buildout/eggs/zc.buildout-2.5.3-py3.4.egg/zc/buildout/buildout.py", line 1995, in main
    getattr(buildout, command)(args)
  File "/opt/boss/.buildout/eggs/zc.buildout-2.5.3-py3.4.egg/zc/buildout/buildout.py", line 666, in install
    installed_files = self[part]._call(recipe.install)
  File "/opt/boss/.buildout/eggs/zc.buildout-2.5.3-py3.4.egg/zc/buildout/buildout.py", line 1410, in _call
    return f()
  File "/opt/boss/eggs/collective.recipe.cmd-0.11-py3.4.egg/collective/recipe/cmd/__init__.py", line 56, in install
    self.execute()
  File "/opt/boss/eggs/collective.recipe.cmd-0.11-py3.4.egg/collective/recipe/cmd/__init__.py", line 69, in execute
    run_commands(cmds, self.shell)
  File "/opt/boss/eggs/collective.recipe.cmd-0.11-py3.4.egg/collective/recipe/cmd/__init__.py", line 39, in run_commands
    check_call('%s %s' % (shell, tmpfile), shell=True)
  File "/usr/lib/python3.4/subprocess.py", line 561, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'sh /tmp/tmprbxr2129/run' returned non-zero exit status 1

这就是我的 gulpfile.js 的样子。

var gulp = require('gulp'),
  extractTranslate = require('gulp-angular-translate-extractor');


    gulp.task('i18n', function () {
      var i18ndest = './assets/translations';
      return gulp.src([
          '!../shared/skyline/**/*.tpl.html',
          '!../shared/skyline/**/*.js',
          '!../shared/openstackService/**/*.js',
          '../shared/**/*.tpl.html',
          '../shared/**/*.js',
          './src/**/*.tpl.html',
          './src/**/*.js',
          './lib/**/*.tpl.html',
          './lib/**/*.js'
        ])
        .pipe(extractTranslate({
          defaultLang: 'en.i18n',
          lang: ['en.i18n', 'ru.i18n'],
          dest: i18ndest,
          safeMode: false, // do not delete old translations
          stringifyOptions: true // force json to be sorted
        }))
        .pipe(gulp.dest(i18ndest));
    });
    ~                                 

这是 frontend/admin

的构建手册
cd <project-dir>/frontend/admin
    npm install
    npm run install
    npm run compile
    The last command creates 'bin' folder with compiled and minified admin frontend.

    npm run dev
    The command places built code inside a build folder, start local web server with livereload and watchers to rebuild app on files changes.

    npm run i18n
    The command extracts all translations keys for angular translate and place them to admin/src/assets/translations

    npm run test
    The command runs karma tests

这是 frontend/lk

的构建手册
 cd <project-dir>/frontend/admin
    npm install
    npm run install
    npm run build
    The last command creates 'bin' folder with compiled and minified admin frontend.

    npm run dev
    The command places built code inside a build folder, start local web server with livereload and watchers to rebuild app on files changes.

    npm run i18n
    The command extracts all translations keys for angular translate and place them to admin/src/assets/translations

    npm run test

The command runs karma tests

如何修复 [20:47:43] Task 'build' is not in your gulpfile 错误?

需要你的帮助。谢谢。

回答您的问题:当您 运行 gulp x 时,您的 gulpfile.js 必须包括

gulp.task('x' ... );

在您的情况下,您可以 运行 gulp i18n,这将 运行 名为 i18n 的任务,或者您可以将 i18n 任务重命名为 build 然后 运行 gulp build.


注意这里发生了很多事情。首先,您似乎还没有初始化 package.json - 这就是

npm WARN package.json boss-admin@1.0.0 No description
npm WARN package.json boss-admin@1.0.0 No README data
npm WARN package.json angular-perfect-scrollbar@0.0.5 No repository field.
npm WARN package.json eslint-plugin-class-property@0.0.3 No repository field.

来自。 运行

npm init

它会引导您完成初始化(您需要先备份当前的 package.json)。

我建议您先完成 https://css-tricks.com/gulp-for-beginners/