nitro 2.2.28 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +11 -259
- package/dist/_chunks/app.mjs +19797 -0
- package/dist/_chunks/build.mjs +84 -0
- package/dist/_chunks/build2.mjs +318 -0
- package/dist/_chunks/build3.mjs +6452 -0
- package/dist/_chunks/detect-acorn.mjs +503 -0
- package/dist/_chunks/index.mjs +22242 -0
- package/dist/_chunks/index2.mjs +297 -0
- package/dist/_chunks/index3.mjs +1058 -0
- package/dist/_chunks/index4.mjs +1206 -0
- package/dist/_chunks/info.mjs +11157 -0
- package/dist/_chunks/json5.mjs +68 -0
- package/dist/_chunks/jsonc.mjs +51 -0
- package/dist/_chunks/pathe.M-eThtNZ.mjs +204 -0
- package/dist/_chunks/plugin.mjs +960 -0
- package/dist/_chunks/server.mjs +254 -0
- package/dist/_chunks/snapshot.mjs +284 -0
- package/dist/_chunks/toml.mjs +259 -0
- package/dist/_chunks/yaml.mjs +86 -0
- package/dist/cli/build.mjs +54 -0
- package/dist/cli/common.mjs +13 -0
- package/dist/cli/dev.mjs +95 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +477 -0
- package/dist/cli/index2.mjs +17 -0
- package/dist/cli/list.mjs +34 -0
- package/dist/cli/prepare.mjs +24 -0
- package/dist/cli/run.mjs +60 -0
- package/dist/index.d.mts +52 -0
- package/dist/index.mjs +55 -0
- package/dist/node_modules/@poppinss/colors/build/index.js +169 -0
- package/dist/node_modules/@poppinss/colors/package.json +116 -0
- package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +717 -0
- package/dist/node_modules/@poppinss/dumper/package.json +122 -0
- package/dist/node_modules/@poppinss/exception/build/index.js +63 -0
- package/dist/node_modules/@poppinss/exception/package.json +106 -0
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +1313 -0
- package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
- package/dist/node_modules/@sindresorhus/is/package.json +81 -0
- package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
- package/dist/node_modules/@speed-highlight/core/package.json +90 -0
- package/dist/node_modules/cookie/dist/index.js +239 -0
- package/dist/node_modules/cookie/package.json +42 -0
- package/dist/node_modules/croner/dist/croner.js +1 -0
- package/dist/node_modules/croner/package.json +63 -0
- package/dist/node_modules/defu/dist/defu.mjs +69 -0
- package/dist/node_modules/defu/package.json +43 -0
- package/dist/node_modules/destr/dist/index.mjs +72 -0
- package/dist/node_modules/destr/package.json +47 -0
- package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
- package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
- package/dist/node_modules/error-stack-parser-es/package.json +83 -0
- package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
- package/dist/node_modules/get-port-please/package.json +39 -0
- package/dist/node_modules/hookable/dist/index.mjs +290 -0
- package/dist/node_modules/hookable/package.json +49 -0
- package/dist/node_modules/kleur/index.js +110 -0
- package/dist/node_modules/kleur/index.mjs +110 -0
- package/dist/node_modules/kleur/package.json +51 -0
- package/dist/node_modules/klona/dist/index.mjs +81 -0
- package/dist/node_modules/klona/full/index.mjs +53 -0
- package/dist/node_modules/klona/package.json +74 -0
- package/dist/node_modules/scule/dist/index.mjs +80 -0
- package/dist/node_modules/scule/package.json +43 -0
- package/dist/node_modules/source-map/lib/array-set.js +100 -0
- package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
- package/dist/node_modules/source-map/lib/base64.js +19 -0
- package/dist/node_modules/source-map/lib/binary-search.js +113 -0
- package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
- package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
- package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
- package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
- package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
- package/dist/node_modules/source-map/lib/source-node.js +430 -0
- package/dist/node_modules/source-map/lib/url.js +13 -0
- package/dist/node_modules/source-map/lib/util.js +444 -0
- package/dist/node_modules/source-map/lib/wasm.js +138 -0
- package/dist/node_modules/source-map/package.json +79 -0
- package/dist/node_modules/source-map/source-map.js +10 -0
- package/dist/node_modules/std-env/dist/index.mjs +1 -0
- package/dist/node_modules/std-env/package.json +46 -0
- package/dist/node_modules/supports-color/index.js +202 -0
- package/dist/node_modules/supports-color/package.json +64 -0
- package/dist/node_modules/ufo/dist/index.mjs +638 -0
- package/dist/node_modules/ufo/package.json +47 -0
- package/dist/node_modules/unctx/dist/index.mjs +131 -0
- package/dist/node_modules/unctx/package.json +67 -0
- package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +42 -0
- package/dist/node_modules/youch/build/chunk-4XB2BYKC.js +85 -0
- package/dist/node_modules/youch/build/chunk-4YEN7HVQ.js +61 -0
- package/dist/node_modules/youch/build/chunk-EUJBVOYB.js +83 -0
- package/dist/node_modules/youch/build/chunk-HFSXRSKS.js +85 -0
- package/dist/node_modules/youch/build/chunk-JAN2TFI2.js +222 -0
- package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +6 -0
- package/dist/node_modules/youch/build/chunk-PINJDICN.js +72 -0
- package/dist/node_modules/youch/build/chunk-PUHGL6HA.js +41 -0
- package/dist/node_modules/youch/build/chunk-VE4LENUR.js +45 -0
- package/dist/node_modules/youch/build/index.js +352 -0
- package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
- package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
- package/dist/node_modules/youch/build/public/error_info/style.css +144 -0
- package/dist/node_modules/youch/build/public/error_stack/script.js +74 -0
- package/dist/node_modules/youch/build/public/error_stack/style.css +220 -0
- package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
- package/dist/node_modules/youch/build/public/header/script.js +16 -0
- package/dist/node_modules/youch/build/public/header/style.css +56 -0
- package/dist/node_modules/youch/build/public/layout/script.js +20 -0
- package/dist/node_modules/youch/build/public/layout/style.css +431 -0
- package/dist/node_modules/youch/package.json +133 -0
- package/dist/node_modules/youch-core/build/index.js +316 -0
- package/dist/node_modules/youch-core/package.json +124 -0
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +62 -0
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +3 -0
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +18 -0
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +21 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +13 -0
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +18 -0
- package/dist/presets/aws-lambda/runtime/_utils.mjs +102 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +3 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +33 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +3 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
- package/dist/presets/azure/runtime/_utils.d.mts +2 -0
- package/dist/presets/azure/runtime/_utils.mjs +50 -0
- package/dist/presets/azure/runtime/azure-swa.d.mts +5 -0
- package/dist/presets/azure/runtime/azure-swa.mjs +28 -0
- package/dist/presets/bun/runtime/bun.d.mts +1 -0
- package/dist/presets/bun/runtime/bun.mjs +27 -0
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +13 -0
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +93 -0
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +19 -0
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +74 -0
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +9 -0
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +20 -0
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +20 -0
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +47 -0
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +3 -0
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +89 -0
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +17 -0
- package/dist/presets/deno/runtime/deno-server.d.mts +6 -0
- package/dist/presets/deno/runtime/deno-server.mjs +59 -0
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +3 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +17 -0
- package/dist/presets/netlify/runtime/netlify.d.mts +3 -0
- package/dist/presets/netlify/runtime/netlify.mjs +24 -0
- package/dist/presets/node/runtime/node-cluster.d.mts +1 -0
- package/dist/presets/node/runtime/node-cluster.mjs +58 -0
- package/dist/presets/node/runtime/node-middleware.d.mts +4 -0
- package/dist/presets/node/runtime/node-middleware.mjs +14 -0
- package/dist/presets/node/runtime/node-server.d.mts +3 -0
- package/dist/presets/node/runtime/node-server.mjs +44 -0
- package/dist/presets/standard/runtime/server.d.mts +5 -0
- package/dist/presets/standard/runtime/server.mjs +6 -0
- package/dist/presets/stormkit/runtime/stormkit.d.mts +21 -0
- package/dist/presets/stormkit/runtime/stormkit.mjs +28 -0
- package/dist/presets/vercel/runtime/vercel.d.mts +8 -0
- package/dist/presets/vercel/runtime/vercel.mjs +17 -0
- package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +87 -0
- package/dist/presets/zeabur/runtime/zeabur.d.mts +3 -0
- package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
- package/dist/presets.mjs +2460 -0
- package/dist/runtime/index.d.mts +11 -0
- package/dist/runtime/index.mjs +17 -0
- package/dist/runtime/internal/app.d.mts +2 -0
- package/dist/runtime/internal/app.mjs +153 -0
- package/dist/runtime/internal/cache.d.mts +7 -0
- package/dist/runtime/internal/cache.mjs +236 -0
- package/dist/runtime/internal/context.d.mts +12 -0
- package/dist/runtime/internal/context.mjs +17 -0
- package/dist/runtime/internal/database.d.mts +2 -0
- package/dist/runtime/internal/database.mjs +14 -0
- package/dist/runtime/internal/debug.d.mts +2 -0
- package/dist/runtime/internal/debug.mjs +5 -0
- package/dist/runtime/internal/empty.d.mts +0 -0
- package/dist/runtime/internal/empty.mjs +0 -0
- package/dist/runtime/internal/error/dev.d.mts +9 -0
- package/dist/runtime/internal/error/dev.mjs +122 -0
- package/dist/runtime/internal/error/prod.d.mts +8 -0
- package/dist/runtime/internal/error/prod.mjs +62 -0
- package/dist/runtime/internal/error/utils.d.mts +8 -0
- package/dist/runtime/internal/error/utils.mjs +3 -0
- package/dist/runtime/internal/index.d.mts +3 -0
- package/dist/runtime/internal/index.mjs +3 -0
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +16 -0
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +213 -0
- package/dist/runtime/internal/meta.d.mts +2 -0
- package/dist/runtime/internal/meta.mjs +3 -0
- package/dist/runtime/internal/plugin.d.mts +3 -0
- package/dist/runtime/internal/plugin.mjs +4 -0
- package/dist/runtime/internal/renderer.d.mts +3 -0
- package/dist/runtime/internal/renderer.mjs +36 -0
- package/dist/runtime/internal/route-rules.d.mts +8 -0
- package/dist/runtime/internal/route-rules.mjs +62 -0
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
- package/dist/runtime/internal/routes/dev-tasks.mjs +23 -0
- package/dist/runtime/internal/routes/openapi.d.mts +3 -0
- package/dist/runtime/internal/routes/openapi.mjs +100 -0
- package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +21 -0
- package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
- package/dist/runtime/internal/routes/scalar.d.mts +3 -0
- package/dist/runtime/internal/routes/scalar.mjs +194 -0
- package/dist/runtime/internal/routes/swagger.d.mts +3 -0
- package/dist/runtime/internal/routes/swagger.mjs +44 -0
- package/dist/runtime/internal/runtime-config.d.mts +9 -0
- package/dist/runtime/internal/runtime-config.mjs +49 -0
- package/dist/runtime/internal/shutdown.d.mts +9 -0
- package/dist/runtime/internal/shutdown.mjs +34 -0
- package/dist/runtime/internal/static.d.mts +3 -0
- package/dist/runtime/internal/static.mjs +77 -0
- package/dist/runtime/internal/storage.d.mts +2 -0
- package/dist/runtime/internal/storage.mjs +6 -0
- package/dist/runtime/internal/task.d.mts +17 -0
- package/dist/runtime/internal/task.mjs +73 -0
- package/dist/runtime/internal/utils.d.mts +1 -0
- package/dist/runtime/internal/utils.mjs +15 -0
- package/dist/runtime/internal/vite/dev-entry.d.mts +1 -0
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -0
- package/dist/runtime/internal/vite/dev-worker.d.mts +1 -0
- package/dist/runtime/internal/vite/dev-worker.mjs +362 -0
- package/dist/runtime/internal/vite/prod-setup.d.mts +4 -0
- package/dist/runtime/internal/vite/prod-setup.mjs +55 -0
- package/dist/runtime/internal/vite/ssr-renderer.d.mts +4 -0
- package/dist/runtime/internal/vite/ssr-renderer.mjs +4 -0
- package/dist/types/index.d.mts +2810 -0
- package/dist/types/index.mjs +1 -0
- package/dist/vite.d.mts +59 -0
- package/dist/vite.mjs +68 -0
- package/lib/config.d.mts +9 -0
- package/lib/config.mjs +5 -0
- package/lib/deps/h3.d.mts +1 -0
- package/lib/deps/h3.mjs +1 -0
- package/lib/deps/ofetch.mjs +1 -0
- package/lib/deps/ofetch.mts +1 -0
- package/lib/meta.d.mts +5 -0
- package/lib/meta.mjs +21 -0
- package/lib/runtime-meta.d.mts +5 -0
- package/lib/runtime-meta.mjs +38 -0
- package/package.json +190 -36
- package/.editorconfig +0 -12
- package/.eslintrc.js +0 -34
- package/.travis.yml +0 -7
- package/Dockerfile +0 -12
- package/Makefile +0 -37
- package/bin/nitro +0 -55
- package/lib/auto-require.js +0 -44
- package/lib/class-file.js +0 -105
- package/lib/class-files.js +0 -212
- package/lib/color.js +0 -89
- package/lib/cwd.js +0 -27
- package/lib/dir-expand.js +0 -80
- package/lib/dir.js +0 -130
- package/lib/file.js +0 -80
- package/lib/join-paths.js +0 -60
- package/lib/livereload/livereload.js +0 -55
- package/lib/livereload.js +0 -86
- package/lib/nitro.js +0 -161
- package/lib/package.js +0 -211
- package/lib/presets/autoprefixer.js +0 -11
- package/lib/presets/babel.js +0 -33
- package/lib/presets/browserify.js +0 -106
- package/lib/presets/coffee-script.js +0 -29
- package/lib/presets/cssnano.js +0 -11
- package/lib/presets/eslint.js +0 -67
- package/lib/presets/jshint.js +0 -51
- package/lib/presets/less.js +0 -45
- package/lib/presets/log.js +0 -11
- package/lib/presets/ng-annotate.js +0 -34
- package/lib/presets/noop.js +0 -7
- package/lib/presets/postcss/auto-postcss.js +0 -46
- package/lib/presets/postcss/autoprefixer-options.js +0 -9
- package/lib/presets/postcss.js +0 -40
- package/lib/presets/rollup.js +0 -56
- package/lib/presets/sass.js +0 -64
- package/lib/presets/sitemap.js +0 -101
- package/lib/presets/sitemap.xml +0 -12
- package/lib/presets/svg-symbols.js +0 -22
- package/lib/presets/svgo.js +0 -21
- package/lib/presets/uglify.js +0 -72
- package/lib/presets/webpack.js +0 -66
- package/lib/processors.js +0 -84
- package/lib/promisify.js +0 -16
- package/lib/server.js +0 -224
- package/lib/tasks.js +0 -114
- package/lib/watch.js +0 -81
- package/test.js +0 -59
- package/tests/cwd-tests.js +0 -25
- package/tests/dir-tests.js +0 -80
- package/tests/dummy/dummy.coffee +0 -7
- package/tests/dummy/dummy.js +0 -8
- package/tests/dummy/dummy.less +0 -6
- package/tests/dummy/dummy.sass +0 -5
- package/tests/file-tests.js +0 -17
- package/tests/join-paths-tests.js +0 -86
- package/tests/tasks-tests.js +0 -65
- package/wercker.yml +0 -25
package/lib/presets/sitemap.xml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<urlset
|
|
3
|
-
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
4
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
5
|
-
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
|
6
|
-
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
|
7
|
-
|
|
8
|
-
$each{ location in locations }<url>
|
|
9
|
-
<loc>${baseUrl}${location.url}</loc>
|
|
10
|
-
<lastmod>${location.stamp}</lastmod>
|
|
11
|
-
</url>{/}
|
|
12
|
-
</urlset>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = function (_nitro) {
|
|
4
|
-
|
|
5
|
-
return function (list, options) {
|
|
6
|
-
options = options || {};
|
|
7
|
-
|
|
8
|
-
var svg = '<svg xmlns="http://www.w3.org/2000/svg">';
|
|
9
|
-
|
|
10
|
-
list.each(function (f) {
|
|
11
|
-
svg += '\n' + f.src
|
|
12
|
-
.replace(/^(.|\n)*?<svg/, '<symbol id="' + f.path.split('/').pop().replace(/\.svg$/, '') + '"')
|
|
13
|
-
.replace(/\s*xmlns:\w+=".*?"/g, '')
|
|
14
|
-
.replace(/<\/svg>/, '</symbol>');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return list.join(options.file_name || 'symbols.svg').each(function (f) {
|
|
18
|
-
f.src = svg + '</svg>';
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
};
|
package/lib/presets/svgo.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = function (nitro) {
|
|
4
|
-
|
|
5
|
-
var SVGO = nitro.require('svgo');
|
|
6
|
-
|
|
7
|
-
return function (list, options) {
|
|
8
|
-
|
|
9
|
-
var svgo = new SVGO(options || {}),
|
|
10
|
-
optimize = nitro.deasync(function (f, callback) {
|
|
11
|
-
svgo.optimize(f.src, { path: f.path }).then(function (result) {
|
|
12
|
-
callback(null, result.data);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
return list.each(function (f) {
|
|
17
|
-
f.src = optimize(f);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
};
|
package/lib/presets/uglify.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = function (nitro) {
|
|
4
|
-
|
|
5
|
-
var uglify = nitro.require('uglify-js'),
|
|
6
|
-
_ = nitro.tools,
|
|
7
|
-
color = require('../color'),
|
|
8
|
-
getRatioLog = function (ratio) {
|
|
9
|
-
var ratio_color = 'cyan', compression = 1 - ratio;
|
|
10
|
-
if( compression < 0.2 ) ratio_color = 'yellow';
|
|
11
|
-
else if( compression > 0.7 ) ratio_color = 'green';
|
|
12
|
-
return color[ratio_color]('[' + Math.round(10000*compression)/100 + '%]');
|
|
13
|
-
},
|
|
14
|
-
sizeK = function (o) {
|
|
15
|
-
if( !o || !o.length ) return o;
|
|
16
|
-
return Math.round(o.length/1000) + 'k';
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return function (list, options) {
|
|
20
|
-
options = _.extend({ expand: true }, options || {}, { fromString: true });
|
|
21
|
-
|
|
22
|
-
list.forEach(function (f) {
|
|
23
|
-
var o = {}, result;
|
|
24
|
-
o[f.path] = f.src;
|
|
25
|
-
|
|
26
|
-
// @TODO imeplemt sourceMap
|
|
27
|
-
// o[f.path] = f.src + f.map ? ( '//# sourceMappingURL=data:application/json;charset=utf-8;base64,' + ) : '';
|
|
28
|
-
// if( f.map ) console.log('map', typeof f.map );
|
|
29
|
-
|
|
30
|
-
try{
|
|
31
|
-
console.log('\nuglifing', color.yellow(f.path), f.src.split('\n').length + color.white(' lines') );
|
|
32
|
-
result = uglify.minify(o);
|
|
33
|
-
|
|
34
|
-
if (result.error) throw result.error;
|
|
35
|
-
console.log( '\n' + getRatioLog(result.code.length/f.src.length), color.magenta( sizeK(f.src) ) + color.white(' => ') + color.cyan( sizeK(result.code) ) + '\n' );
|
|
36
|
-
|
|
37
|
-
} catch(err) {
|
|
38
|
-
var code_lines = f.src.split('\n');
|
|
39
|
-
|
|
40
|
-
console.log( '\n' + color.red(err.message) );
|
|
41
|
-
console.log( '\nfile: ' + color.white( f.cwd + ( /\/$/.test(f.cwd) ? '' : '/' ) ) + color.yellow(err.filename) );
|
|
42
|
-
|
|
43
|
-
if( err.line ) {
|
|
44
|
-
console.log( color.white('\n--------------------------------------------------------------------------------') );
|
|
45
|
-
console.log('line: ', color.cyan(err.line) + ' col: ' + color.magenta(err.col) );
|
|
46
|
-
console.log( color.white('--------------------------------------------------------------------------------\n') );
|
|
47
|
-
console.log( code_lines.slice(err.line - 5, err.line).join('\n') );
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// https://www.w3schools.com/charsets/ref_utf_symbols.asp
|
|
51
|
-
if( err.col ) console.log(' '.repeat(err.col) + color.yellow('🖢') );
|
|
52
|
-
console.log( color.white('--------------------------------------------------------------------------------\n') );
|
|
53
|
-
|
|
54
|
-
console.log('\n', err );
|
|
55
|
-
|
|
56
|
-
throw err;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if( options.sourceMap ) {
|
|
60
|
-
f.src = result.code.replace(/\n\/\/[^\n]+\.js\.map$/, '');
|
|
61
|
-
f.map = result.map;
|
|
62
|
-
} else {
|
|
63
|
-
f.src = result.code;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return list;
|
|
69
|
-
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
};
|
package/lib/presets/webpack.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports = function (nitro) {
|
|
3
|
-
|
|
4
|
-
var webpack = nitro.require('webpack')
|
|
5
|
-
|
|
6
|
-
return function (list, options) {
|
|
7
|
-
|
|
8
|
-
if( !options || (!options.output && (!options.config || !options.config.output) ) ) {
|
|
9
|
-
throw new Error('output config should be defined')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
var _config = Object.assign( options.output ? { output: options.output } : {}, options.config || {})
|
|
13
|
-
|
|
14
|
-
if( !_config.module ) _config.module = {}
|
|
15
|
-
if( !_config.module.rules ) _config.module.rules = []
|
|
16
|
-
|
|
17
|
-
if( !_config.plugins ) _config.plugins = []
|
|
18
|
-
if( options.plugins ) _config.plugins.push.apply(_config.plugins, options.plugins)
|
|
19
|
-
|
|
20
|
-
if( options.virtual ) (function (VirtualModulesPlugin) {
|
|
21
|
-
_config.plugins.push( new VirtualModulesPlugin(options.virtual) )
|
|
22
|
-
})(nitro.require("webpack-virtual-modules"))
|
|
23
|
-
|
|
24
|
-
if( options.alias ) {
|
|
25
|
-
_config.resolve = _config.resolve || {}
|
|
26
|
-
_config.resolve.alias = Object.assign(Object.assign({}, options.alias), _config.resolve.alias || {})
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if( options.babel ) {
|
|
30
|
-
_config.module.rules.push({
|
|
31
|
-
test: /\.m?js$/,
|
|
32
|
-
exclude: /(node_modules|bower_components)/,
|
|
33
|
-
use: {
|
|
34
|
-
loader: 'babel-loader',
|
|
35
|
-
options: options.babel
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var bundle = nitro.deasync(function (f, callback) {
|
|
41
|
-
|
|
42
|
-
var __config = Object.assign({
|
|
43
|
-
entry: f.full_path,
|
|
44
|
-
}, _config)
|
|
45
|
-
|
|
46
|
-
console.log('webpack', __config)
|
|
47
|
-
|
|
48
|
-
webpack(__config, function (err, stats) {
|
|
49
|
-
if( err || stats.hasErrors() ) {
|
|
50
|
-
// Handle errors here
|
|
51
|
-
console.log(err)
|
|
52
|
-
console.log(stats)
|
|
53
|
-
process.exit(2)
|
|
54
|
-
} else {
|
|
55
|
-
callback(null, stats)
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
return list.each(function (f) {
|
|
62
|
-
bundle(f)
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
}
|
package/lib/processors.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var file = require('./file'),
|
|
4
|
-
Files = require('./class-files'),
|
|
5
|
-
joinPaths = require('./join-paths'),
|
|
6
|
-
_ = require('nitro-tools'),
|
|
7
|
-
process_cwd = joinPaths.root(),
|
|
8
|
-
processors = {};
|
|
9
|
-
|
|
10
|
-
var processorsCache = {},
|
|
11
|
-
presets = {};
|
|
12
|
-
|
|
13
|
-
function processorWrapper (processor) {
|
|
14
|
-
return function (list, options) {
|
|
15
|
-
var result, cwd = process.cwd();
|
|
16
|
-
options = options || {};
|
|
17
|
-
|
|
18
|
-
// if( options.cwd || list.cwd ) process.chdir( joinPaths.root(options.cwd || list.cwd) );
|
|
19
|
-
// else process.chdir(process_cwd);
|
|
20
|
-
|
|
21
|
-
result = processor.call( list, list, _.extend(list.options.sourceMap ? { sourceMap: list.options.sourceMap } : {}, options) );
|
|
22
|
-
|
|
23
|
-
// process.chdir(cwd);
|
|
24
|
-
|
|
25
|
-
return result instanceof Files ? result : list;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function registerProcessor (methodName, processor, thisArg) {
|
|
30
|
-
processorsCache[methodName] = processorWrapper(processor);
|
|
31
|
-
return thisArg;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function loadPreset (preset) {
|
|
35
|
-
var preset_file = joinPaths( __dirname, './presets/' + preset + '.js' );
|
|
36
|
-
if( !presets[preset] && file.exists( preset_file ) ) {
|
|
37
|
-
presets[preset] = processorWrapper( require(preset_file)(require('./nitro')) );
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if( !presets[preset] ) throw new Error('preset not found: ' + preset);
|
|
41
|
-
|
|
42
|
-
return presets[preset];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
Files.prototype.process = function (pattern, processorName, options) {
|
|
46
|
-
|
|
47
|
-
if( !_.isString(processorName) ) {
|
|
48
|
-
if( _.isObject(processorName) ) options = processorName;
|
|
49
|
-
|
|
50
|
-
processorName = pattern;
|
|
51
|
-
pattern = undefined;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var processor = processorsCache[processorName] || loadPreset( processorName );
|
|
55
|
-
|
|
56
|
-
if( !processor ) throw new Error('file processor missing: ' + processorName);
|
|
57
|
-
|
|
58
|
-
var list = this.clone();
|
|
59
|
-
|
|
60
|
-
if( pattern ) {
|
|
61
|
-
|
|
62
|
-
var indexes_matched = [],
|
|
63
|
-
filtered_list = new Files([], Object.create(this.options) );
|
|
64
|
-
|
|
65
|
-
list.each(pattern, function (f, i) {
|
|
66
|
-
indexes_matched.push(i);
|
|
67
|
-
filtered_list.push(f);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
filtered_list = processor.call( filtered_list, filtered_list, options ) || filtered_list;
|
|
71
|
-
|
|
72
|
-
for( var i = 0 ; i < indexes_matched.length ; i++ ) list[indexes_matched[i]] = filtered_list[i];
|
|
73
|
-
|
|
74
|
-
return list;
|
|
75
|
-
} else {
|
|
76
|
-
return processor.call( list, list, options ) || list;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
_.extend(processors, {
|
|
81
|
-
register: registerProcessor,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
module.exports = processors;
|
package/lib/promisify.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var Parole = require('parole');
|
|
3
|
-
|
|
4
|
-
function promisify (fn) {
|
|
5
|
-
return function () {
|
|
6
|
-
var _this = this, _args = arguments;
|
|
7
|
-
return new Parole(function (resolve, reject) {
|
|
8
|
-
fn.apply(_this, _args.concat([function (err, result) {
|
|
9
|
-
if( err ) reject(err);
|
|
10
|
-
else resolve(result);
|
|
11
|
-
}]) );
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = promisify;
|
package/lib/server.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var http = require('http'),
|
|
4
|
-
url = require('url'),
|
|
5
|
-
joinPaths = require('./join-paths'),
|
|
6
|
-
fs = require('fs'),
|
|
7
|
-
Parole = require('parole'),
|
|
8
|
-
color = require('./color'),
|
|
9
|
-
mime = require('mime'),
|
|
10
|
-
livereload = require('./livereload'),
|
|
11
|
-
open = require('open');
|
|
12
|
-
|
|
13
|
-
if( !mime.getType ) mime.getType = mime.lookup;
|
|
14
|
-
|
|
15
|
-
function extend () {
|
|
16
|
-
var dest = [].shift.call(arguments),
|
|
17
|
-
src = [].shift.call(arguments),
|
|
18
|
-
key;
|
|
19
|
-
|
|
20
|
-
while( src ) {
|
|
21
|
-
for( key in src) {
|
|
22
|
-
dest[key] = src[key];
|
|
23
|
-
}
|
|
24
|
-
src = [].shift.call(arguments);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return dest;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function noop (value) { return value; }
|
|
31
|
-
|
|
32
|
-
function clearSlash (path_str) {
|
|
33
|
-
return path_str.replace(/^\/|\/$/g,'');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function qStat (filepath) {
|
|
37
|
-
return new Parole(function (resolve, reject) {
|
|
38
|
-
fs.stat(filepath, function (err, stat) {
|
|
39
|
-
if( err !== null ) {
|
|
40
|
-
reject(filepath);
|
|
41
|
-
}
|
|
42
|
-
resolve(stat);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function tryFilesFn (basePath, uri, tryFiles) {
|
|
48
|
-
var filepath = tryFiles.shift();
|
|
49
|
-
|
|
50
|
-
if( !filepath ) {
|
|
51
|
-
return Parole.reject();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
filepath = basePath.replace(/\/$/, '') + '/' + filepath.replace(/^\//, '').replace(/\$uri/, uri);
|
|
55
|
-
|
|
56
|
-
return qStat(filepath).then(function (stat) {
|
|
57
|
-
|
|
58
|
-
if( stat.isDirectory() ) {
|
|
59
|
-
filepath += ( ( /\/$/.test(filepath) ? '' : '/' ) + 'index.html' );
|
|
60
|
-
|
|
61
|
-
return qStat( filepath ).then(function () {
|
|
62
|
-
return filepath;
|
|
63
|
-
});
|
|
64
|
-
} else if( !stat.isFile() ) {
|
|
65
|
-
throw 'uri is not a file';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return filepath;
|
|
69
|
-
}).catch(function () {
|
|
70
|
-
return tryFilesFn(basePath, uri, tryFiles);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
var defaultOptions = {
|
|
75
|
-
protocol: 'http',
|
|
76
|
-
hostname: '0.0.0.0',
|
|
77
|
-
port: 8080,
|
|
78
|
-
root: '.',
|
|
79
|
-
keepalive: false,
|
|
80
|
-
debug: false,
|
|
81
|
-
livereload: false,
|
|
82
|
-
open: false,
|
|
83
|
-
dirAlias: {},
|
|
84
|
-
onStart: noop,
|
|
85
|
-
onStop: noop,
|
|
86
|
-
log: true
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
function runServer (rootpath, options) {
|
|
90
|
-
options = options || {};
|
|
91
|
-
|
|
92
|
-
if( typeof rootpath === 'object' && rootpath != null ) {
|
|
93
|
-
options = rootpath;
|
|
94
|
-
} else {
|
|
95
|
-
options.root = rootpath;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
options = extend( Object.create(defaultOptions), options);
|
|
99
|
-
|
|
100
|
-
if( options.debug ) {
|
|
101
|
-
console.log('options : ' + JSON.stringify(options));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
var matchAlias = {};
|
|
105
|
-
Object.keys(options.dirAlias).forEach(function(dir){
|
|
106
|
-
matchAlias[dir] = new RegExp('^' + clearSlash(dir));
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
var documentRoot = joinPaths.root(options.root);
|
|
110
|
-
var server = http.createServer(function(request, response) {
|
|
111
|
-
|
|
112
|
-
var uri = url.parse(request.url).pathname,
|
|
113
|
-
uriClear = clearSlash(uri),
|
|
114
|
-
uriLog = uri,
|
|
115
|
-
basePath = documentRoot,
|
|
116
|
-
// filename = path.join(basePath, uri),
|
|
117
|
-
contentType = 'text/plain';
|
|
118
|
-
|
|
119
|
-
// if( options.addExtension && /[a-z]$/.test(filename) && !/[a-z]+\.[a-z]+$/.test(filename) ) {
|
|
120
|
-
// filename += '.' + options.addExtension;
|
|
121
|
-
// }
|
|
122
|
-
|
|
123
|
-
if( options.headers ) {
|
|
124
|
-
for( var header in options.headers ) {
|
|
125
|
-
response.setHeader(header, options.headers[header]);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
Object.keys(options.dirAlias).forEach(function (dir) {
|
|
130
|
-
if( matchAlias[dir].test(uriClear) ) {
|
|
131
|
-
var uriRelative = uriClear.replace(matchAlias[dir],'').replace(/^\//,'');
|
|
132
|
-
basePath = joinPaths.root();
|
|
133
|
-
|
|
134
|
-
// filename = path.join( path.resolve(cwd,options.dirAlias[dir]), uriRelative );
|
|
135
|
-
uri = joinPaths( options.dirAlias[dir], uriRelative );
|
|
136
|
-
|
|
137
|
-
uriLog = ( '/' + dir ).blue + '/' + uriRelative;
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
tryFilesFn( basePath, uri.replace(/\/$/, ''), ['$uri'].concat( typeof options.tryFiles === 'string' ? options.tryFiles.split(/\s+/) : (options.tryFiles && options.tryFiles.slice() || ['$uri.html']) ) ).then(function (filepath) {
|
|
142
|
-
|
|
143
|
-
if( /\w+\.\w+/.test(filepath) ) {
|
|
144
|
-
contentType = ( mime.getType( filepath ) || contentType ) + '; charset=UTF-8';
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
fs.readFile(filepath, 'binary', function(err, file) {
|
|
148
|
-
if(err) {
|
|
149
|
-
response.writeHead(500, { 'Content-Type': contentType });
|
|
150
|
-
response.write(err + '\n');
|
|
151
|
-
response.end();
|
|
152
|
-
if(options.log) {
|
|
153
|
-
console.log( color.redBright('[500]') + (' ' + uriLog).cyan );
|
|
154
|
-
}
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
response.writeHead(200, { 'Content-Type': contentType });
|
|
159
|
-
response.write(file, 'binary');
|
|
160
|
-
response.end();
|
|
161
|
-
if(options.log) {
|
|
162
|
-
console.log( color.green('[200]') + uriLog + color.yellow( ' (' + contentType + ')' ) );
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
}, function () {
|
|
167
|
-
|
|
168
|
-
response.writeHead(404, { 'Content-Type': 'text/html; charset=UTF-8'});
|
|
169
|
-
response.write('<div style=\"text-align: center;\"><div style=\"display: inline-block; min-width: 80%; border: 1px solid #999; padding: 0.5em; text-align: left;\"><div><span style=\"color: red;\">404</span> <span style=\"font-weight: bold;\">'+uri+'</span></div><div>Not Found</div></div></div>');
|
|
170
|
-
response.end();
|
|
171
|
-
if( options.log ) {
|
|
172
|
-
console.log( color.redBright('[404]') + color.cyan(' ' + uriLog) );
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
return server.listen(parseInt(options.port, 10), options.hostname,function () {
|
|
180
|
-
var url = ( 'http://'+( ( options.hostname === '0.0.0.0' ) ? 'localhost': options.hostname ) + ':' + options.port );
|
|
181
|
-
|
|
182
|
-
if( options.log ) {
|
|
183
|
-
console.log( color.yellow('\nStatic file server running at\n => ') + color.green(url) + color.yellow('/\nCTRL + C to shutdown\n') );
|
|
184
|
-
// console.log('Root directory is: '.yellow + path.join(cwd, options.root).green + '\n' );
|
|
185
|
-
console.log( color.yellow('Root directory is: ') + color.green(documentRoot) + '\n' );
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if( options.onStart instanceof Function ) {
|
|
189
|
-
options.onStart.call(server, server);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if( options.openInBrowser ) {
|
|
193
|
-
if( typeof options.openInBrowser === 'string' ) open(url, options.openInBrowser);
|
|
194
|
-
else open(url);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if( options.livereload ) {
|
|
198
|
-
var watchDirs = [ options.root ],
|
|
199
|
-
livereloadOptions = ( typeof options.livereload === 'number' ) ? {
|
|
200
|
-
port: options.livereload
|
|
201
|
-
} : ( typeof options.livereload === 'object' ? ( options.livereload || {} ) : {} );
|
|
202
|
-
|
|
203
|
-
for( var d in options.dirAlias ) {
|
|
204
|
-
watchDirs.push( options.dirAlias[d] );
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if( options.log ) {
|
|
208
|
-
console.log( color.cyan('livereload') );
|
|
209
|
-
|
|
210
|
-
console.log( color.yellow(' dirs'), watchDirs);
|
|
211
|
-
console.log( color.yellow(' options'), livereloadOptions);
|
|
212
|
-
console.log('\n');
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
livereload( runServer(__dirname + '/livereload', { port: livereloadOptions.port || 12345, log: false }), watchDirs.map(function (dir) {
|
|
216
|
-
return joinPaths.root(options.cwd, dir);
|
|
217
|
-
}) );
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
// return server;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
module.exports = runServer;
|
package/lib/tasks.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var color = require('./color'),
|
|
5
|
-
Parole = require('parole'),
|
|
6
|
-
promisify = function (result) {
|
|
7
|
-
if( result && result.then instanceof Function ) return result;
|
|
8
|
-
return Parole.resolve(result);
|
|
9
|
-
},
|
|
10
|
-
tasksCache = {},
|
|
11
|
-
registerTask = function () {
|
|
12
|
-
var handlers = [].slice.call(arguments),
|
|
13
|
-
taskName = handlers.shift();
|
|
14
|
-
|
|
15
|
-
if( typeof taskName === 'object' ) {
|
|
16
|
-
|
|
17
|
-
for( var key in taskName ) registerTask(key, taskName[key]);
|
|
18
|
-
|
|
19
|
-
} else if( handlers.length === 1 ) {
|
|
20
|
-
tasksCache[taskName] = handlers[0];
|
|
21
|
-
} else {
|
|
22
|
-
tasksCache[taskName] = handlers;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function tasks () {
|
|
27
|
-
if( arguments.length > 1 ) return registerTask.apply(this, arguments);
|
|
28
|
-
else if( arguments.length === 1 ) return tasks.run.apply(this, arguments);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function runTasksSequence (tasks, target) {
|
|
32
|
-
var task = tasks.shift();
|
|
33
|
-
|
|
34
|
-
if( !task ) return Parole.resolve();
|
|
35
|
-
|
|
36
|
-
return runTask(task, target).then(function () {
|
|
37
|
-
return runTasksSequence(tasks, target);
|
|
38
|
-
}, function (err) {
|
|
39
|
-
console.log(err);
|
|
40
|
-
process.exit(2);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
tasks.register = registerTask;
|
|
45
|
-
|
|
46
|
-
function runTask (task, target, concurrentArray) {
|
|
47
|
-
|
|
48
|
-
if( task instanceof Function ) {
|
|
49
|
-
if( /^function [^(]*\( *[^ ]+ *, *[^ ]+/.test(task.toString()) ) {
|
|
50
|
-
return new Parole(function (resolve, reject) {
|
|
51
|
-
task(target, resolve);
|
|
52
|
-
setTimeout(reject, 300000);
|
|
53
|
-
}).catch(function (err) {
|
|
54
|
-
console.log(err);
|
|
55
|
-
process.exit(2);
|
|
56
|
-
});
|
|
57
|
-
} else return promisify( task(target) );
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if( typeof task === 'string' ) {
|
|
61
|
-
return (function (taskName, target) {
|
|
62
|
-
|
|
63
|
-
if( !tasksCache[taskName] ) {
|
|
64
|
-
console.error( color.yellow('\ntask ') + taskName + (target ? color.cyan(':' + target) : '') + color.red(' not found\n') );
|
|
65
|
-
process.exit(2);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
var startTime = Date.now();
|
|
69
|
-
|
|
70
|
-
return runTask(tasksCache[taskName], target).then(function (result) {
|
|
71
|
-
console.log('\n' + color.green('\ntask ') + taskName + (target ? color.cyan(':' + target) : '') + ' ' + color.yellow( ( Date.now() - startTime ) + 'ms' ) + '\n' );
|
|
72
|
-
return result;
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
}).apply(null, task.split(/:(.+)/) );
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if( task instanceof Array ) {
|
|
79
|
-
if( concurrentArray ) return Parole.all(task.map(function (task) {
|
|
80
|
-
return runTask(task, target);
|
|
81
|
-
}) );
|
|
82
|
-
|
|
83
|
-
return runTasksSequence(task.slice(), target, true);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if( typeof task === 'object' ) {
|
|
87
|
-
|
|
88
|
-
if( !target && !task.default ) {
|
|
89
|
-
console.error('\nno target defined and default task missing\n');
|
|
90
|
-
process.exit(2);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if( target && !task[target] ) {
|
|
94
|
-
console.error('\ntask ' + color.yellow('target') + ' ' + target + color.red(' not found\n') );
|
|
95
|
-
process.exit(2);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return runTask( target ? task[target] : task.default, target);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
tasks.run = function () {
|
|
104
|
-
var tasks = [];
|
|
105
|
-
|
|
106
|
-
for( var i = 0, n = arguments.length ; i < n ; i++ ) {
|
|
107
|
-
if( arguments[i] instanceof Array ) [].push.apply(tasks, arguments[i]);
|
|
108
|
-
else tasks.push(arguments[i]);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return runTasksSequence(tasks);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
module.exports = tasks;
|