nitro 2.2.28 → 3.0.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 +170 -38
- 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/file.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _ = require('nitro-tools'),
|
|
4
|
-
fs = require('fs'),
|
|
5
|
-
joinPaths = require('./join-paths'),
|
|
6
|
-
mkdirp = require('mkdirp'),
|
|
7
|
-
mmatch = require('minimatch'),
|
|
8
|
-
deasync = require('deasync'),
|
|
9
|
-
RE_filepath = /(.*)[\\/](.*)/,
|
|
10
|
-
YAML = require('js-yaml');
|
|
11
|
-
|
|
12
|
-
function parsePath (filepath) {
|
|
13
|
-
var matches = filepath.match(RE_filepath);
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
filename: ( matches && matches[2] ) || filepath,
|
|
17
|
-
filepath: ( matches && matches[1] ) || null
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var file = {
|
|
22
|
-
exists: function (filepath) {
|
|
23
|
-
filepath = joinPaths.root(filepath);
|
|
24
|
-
try {
|
|
25
|
-
return fs.statSync(filepath);
|
|
26
|
-
} catch(err) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
read: function (paths) {
|
|
31
|
-
return fs.readFileSync( joinPaths.root(paths), { encoding: 'utf8' });
|
|
32
|
-
},
|
|
33
|
-
readJSON: function () {
|
|
34
|
-
return JSON.parse( file.read.apply(this, arguments) );
|
|
35
|
-
},
|
|
36
|
-
readYAML: function () {
|
|
37
|
-
return YAML.safeLoad( file.read.apply(this, arguments) );
|
|
38
|
-
},
|
|
39
|
-
write: function (paths, content, options) {
|
|
40
|
-
var dest = joinPaths(paths),
|
|
41
|
-
filepath = parsePath(dest).filepath;
|
|
42
|
-
|
|
43
|
-
if( filepath ) mkdirp.sync(filepath);
|
|
44
|
-
return fs.writeFileSync( joinPaths.root(dest) , content, _.extend({ encoding: 'utf8' }, options || {}) );
|
|
45
|
-
},
|
|
46
|
-
writeJSON: function (paths, data, indentation) {
|
|
47
|
-
return file.write( paths, JSON.stringify(data, null, indentation || '\t') );
|
|
48
|
-
},
|
|
49
|
-
writeYAML: function (paths, data) {
|
|
50
|
-
return file.write( paths, YAML.safeDump(data) );
|
|
51
|
-
},
|
|
52
|
-
copy: function (src, dest) {
|
|
53
|
-
var filepath = parsePath(dest).filepath;
|
|
54
|
-
if( filepath && !file.exists(filepath) ) {
|
|
55
|
-
mkdirp.sync( joinPaths.root(filepath) );
|
|
56
|
-
}
|
|
57
|
-
deasync(function (done) {
|
|
58
|
-
fs.createReadStream(joinPaths.root(src))
|
|
59
|
-
.pipe( fs.createWriteStream( joinPaths.root(dest) ).on('close', done) );
|
|
60
|
-
})();
|
|
61
|
-
return file;
|
|
62
|
-
},
|
|
63
|
-
parsePath: parsePath,
|
|
64
|
-
filter: function (filter) {
|
|
65
|
-
if( typeof filter === 'string' ) {
|
|
66
|
-
return mmatch.filter(filter);
|
|
67
|
-
} else if( filter instanceof Array ) {
|
|
68
|
-
var filters = filter.map(file.filter);
|
|
69
|
-
|
|
70
|
-
return function (filepath) {
|
|
71
|
-
return filters.every(function (fileFilter) {
|
|
72
|
-
return fileFilter(filepath);
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
module.exports = file;
|
package/lib/join-paths.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var arrayPush = Array.prototype.push,
|
|
3
|
-
arraySlice = Array.prototype.slice;
|
|
4
|
-
|
|
5
|
-
function _sanitizePath(path, i, last) {
|
|
6
|
-
if( i > 0 ) path = path.replace(/^\.*\//, '');
|
|
7
|
-
if( !last ) path = path.replace(/\/$/, '');
|
|
8
|
-
return path.split(/\/+/);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function _joinPaths (paths) {
|
|
12
|
-
var last = paths.length - 1;
|
|
13
|
-
return paths.reduce(function (result, path, i) {
|
|
14
|
-
|
|
15
|
-
if( path === '.' ) return result;
|
|
16
|
-
if( /^\//.test(path) ) return _sanitizePath(path, 0, i === last );
|
|
17
|
-
|
|
18
|
-
path = path.replace(/\.\.\//g, function () {
|
|
19
|
-
result = result.slice(0, -1);
|
|
20
|
-
return '';
|
|
21
|
-
}).replace(/\.\//, '');
|
|
22
|
-
|
|
23
|
-
arrayPush.apply( result, _sanitizePath(path, i, i === last) );
|
|
24
|
-
|
|
25
|
-
return result;
|
|
26
|
-
|
|
27
|
-
}, []).join('/');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function _unraise (paths) {
|
|
31
|
-
var result = [];
|
|
32
|
-
|
|
33
|
-
paths.forEach(function (path) {
|
|
34
|
-
if( !path ) return;
|
|
35
|
-
|
|
36
|
-
// https://jsperf.com/array-prototype-push-apply-vs-concat/17
|
|
37
|
-
if( path instanceof Array ) arrayPush.apply(result, _unraise(path) );
|
|
38
|
-
else if( typeof path === 'string' ) result.push(path);
|
|
39
|
-
else throw new Error('paths parts should be Array or String');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function joinPaths () {
|
|
46
|
-
return _joinPaths( _unraise(arraySlice.call(arguments)) );
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// node env
|
|
50
|
-
|
|
51
|
-
var cwd = process.cwd();
|
|
52
|
-
joinPaths.root = function () {
|
|
53
|
-
return joinPaths(cwd, arraySlice.call(arguments) );
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
joinPaths.cwd = function () {
|
|
57
|
-
return joinPaths(process.cwd(), arraySlice.call(arguments) );
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
module.exports = joinPaths;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
/* eslint no-console: 0 */
|
|
3
|
-
|
|
4
|
-
(function () {
|
|
5
|
-
|
|
6
|
-
var currentScript = document.currentScript || (function() {
|
|
7
|
-
var scripts = document.getElementsByTagName('script');
|
|
8
|
-
return scripts[scripts.length - 1];
|
|
9
|
-
})();
|
|
10
|
-
|
|
11
|
-
function updateStyleHref (href) {
|
|
12
|
-
var qs = href.split('?'),
|
|
13
|
-
resource = qs[0];
|
|
14
|
-
|
|
15
|
-
qs = (qs[1] || '').replace(/&livereload=\d+/, '');
|
|
16
|
-
|
|
17
|
-
return resource + '?' + qs + (qs ? '&' : '') + 'livereload=' + new Date().getTime();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var matchedURL = currentScript.src.match(/https?:\/\/(.*?):(\d+)?\//);
|
|
21
|
-
|
|
22
|
-
if( matchedURL ) {
|
|
23
|
-
var ws = new WebSocket('ws://' + matchedURL[1] + ':' + matchedURL[2]);
|
|
24
|
-
|
|
25
|
-
ws.addEventListener('message', function (message) {
|
|
26
|
-
|
|
27
|
-
var files = JSON.parse(message.data).files,
|
|
28
|
-
baseURL = location.protocol + '//' + location.host + '/',
|
|
29
|
-
styles = [];
|
|
30
|
-
|
|
31
|
-
var noMaps = files.filter(function (f) {
|
|
32
|
-
if( /\.css$/.test(f.path) ) styles.push(baseURL + f.path);
|
|
33
|
-
return !/\.map$/.test(f.path);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if( styles.length !== noMaps.length ) {
|
|
37
|
-
ws.close();
|
|
38
|
-
location.reload();
|
|
39
|
-
} else {
|
|
40
|
-
console.log('updating', styles.map(function (f) { return f.path; }) );
|
|
41
|
-
var links = {};
|
|
42
|
-
[].forEach.call(document.querySelectorAll('link[rel=stylesheet]'), function (link) {
|
|
43
|
-
links[ link.href.split('?')[0] ] = link;
|
|
44
|
-
});
|
|
45
|
-
styles.forEach(function (stylePath) {
|
|
46
|
-
if( links[stylePath] ) links[stylePath].href = updateStyleHref(links[stylePath].href);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// console.log('filepaths', filepaths);
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
})();
|
package/lib/livereload.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var ws = require('ws'),
|
|
3
|
-
joinPaths = require('./join-paths'),
|
|
4
|
-
color = require('./color'),
|
|
5
|
-
// fs = require('fs'),
|
|
6
|
-
chokidar = require('chokidar'),
|
|
7
|
-
_remove = function (list, item) {
|
|
8
|
-
for( var i = list.length - 1 ; i >= 0 ; i-- ) {
|
|
9
|
-
if( list[i] === item ) list.splice(i, 1);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
module.exports = function (server, dirpath, options) {
|
|
14
|
-
|
|
15
|
-
options = options || {};
|
|
16
|
-
|
|
17
|
-
var files = [],
|
|
18
|
-
notify,
|
|
19
|
-
listeners = [];
|
|
20
|
-
|
|
21
|
-
(dirpath instanceof Array ? dirpath : [dirpath]).forEach(function (dirpath, i) {
|
|
22
|
-
|
|
23
|
-
// fs.watch(dirpath, { recursive: true }, function (eventType, filepath) {
|
|
24
|
-
// nodeWatch(dirpath, function (filepath, eventType) {
|
|
25
|
-
|
|
26
|
-
var RE_removeBase = new RegExp('^' + joinPaths.root(dirpath) + '\\/');
|
|
27
|
-
|
|
28
|
-
chokidar.watch( joinPaths.root(dirpath), {
|
|
29
|
-
ignoreInitial: true
|
|
30
|
-
}).on('all', function (event, filepath) {
|
|
31
|
-
|
|
32
|
-
files.push({
|
|
33
|
-
path: ( i ? ( dirpath + '/' ) : '' ) + filepath.replace(RE_removeBase, ''),
|
|
34
|
-
event: event,
|
|
35
|
-
time: Date.now()
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
if( notify ) clearTimeout(notify);
|
|
39
|
-
|
|
40
|
-
notify = setTimeout(function () {
|
|
41
|
-
listeners.forEach(function (listener) {
|
|
42
|
-
listener({ files: files, time: Date.now() });
|
|
43
|
-
});
|
|
44
|
-
files.splice(0, files.length);
|
|
45
|
-
clearTimeout(notify);
|
|
46
|
-
}, 400);
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
var socket = new ws.Server({ server: server });
|
|
53
|
-
socket.on('connection', function(w) {
|
|
54
|
-
|
|
55
|
-
var listener = function (data) {
|
|
56
|
-
try {
|
|
57
|
-
if( w.readyState !== ws.OPEN ) return;
|
|
58
|
-
w.send(JSON.stringify(data));
|
|
59
|
-
} catch(err) {
|
|
60
|
-
console.log('livereload.send:error', err);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
listeners.push(listener);
|
|
65
|
-
|
|
66
|
-
// w.on('message', function(msg){
|
|
67
|
-
// console.log('message from client', msg);
|
|
68
|
-
// });
|
|
69
|
-
|
|
70
|
-
w.on('close', function() {
|
|
71
|
-
_remove(listeners, listener);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
var highlight = options.highlight || function (value) { return color.blueBright(value); };
|
|
76
|
-
|
|
77
|
-
function listeningLog() {
|
|
78
|
-
console.log(color.yellow('\nlivereload snippet:') + highlight(`\n
|
|
79
|
-
(function (h,s) {
|
|
80
|
-
s.type='text/javascript';s.src='//' + location.hostname + ':${ server.address().port }/livereload.js';h.appendChild(s);
|
|
81
|
-
})(document.getElementsByTagName('head')[0], document.createElement('script') );\n`) );
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if( server.listening ) listeningLog();
|
|
85
|
-
else server.on('listening', listeningLog);
|
|
86
|
-
};
|
package/lib/nitro.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// useful es6 shim
|
|
3
|
-
if( !Array.prototype.find ) {
|
|
4
|
-
Array.prototype.find = function (iteratee, thisArg) {
|
|
5
|
-
if( typeof iteratee !== 'function' ) throw new TypeError('predicate must be a function');
|
|
6
|
-
|
|
7
|
-
for( var i = 0, n = this.length ; i < n ; i++ ) {
|
|
8
|
-
if( iteratee.call(thisArg, this[i]) ) {
|
|
9
|
-
return this[i];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// nitro declaration
|
|
16
|
-
|
|
17
|
-
var nitro = function (handler) {
|
|
18
|
-
if( handler instanceof Function ) handler(nitro);
|
|
19
|
-
return nitro;
|
|
20
|
-
},
|
|
21
|
-
_ = require('nitro-tools'),
|
|
22
|
-
fs = require('fs'),
|
|
23
|
-
color = require('./color'),
|
|
24
|
-
deasync = require('deasync'),
|
|
25
|
-
noop = function (value) { return value; },
|
|
26
|
-
YAML = require('js-yaml');
|
|
27
|
-
|
|
28
|
-
var file = require('./file'),
|
|
29
|
-
dir = require('./dir'),
|
|
30
|
-
processors = require('./processors'),
|
|
31
|
-
tasks = require('./tasks'),
|
|
32
|
-
joinPaths = require('./join-paths'),
|
|
33
|
-
server = require('./server'),
|
|
34
|
-
livereload = require('./livereload'),
|
|
35
|
-
autoRequire = require('./auto-require'),
|
|
36
|
-
dirExpand = require('./dir-expand');
|
|
37
|
-
|
|
38
|
-
function returnNitro (fn) {
|
|
39
|
-
return function () {
|
|
40
|
-
fn.apply(this, arguments);
|
|
41
|
-
return nitro;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_.extend(nitro, {
|
|
46
|
-
color: color,
|
|
47
|
-
noop: noop,
|
|
48
|
-
cwdRoot: process.cwd(),
|
|
49
|
-
cwd: require('./cwd'),
|
|
50
|
-
joinPaths: joinPaths,
|
|
51
|
-
exec: require('child_process').execSync || deasync( require('child_process').exec ),
|
|
52
|
-
deasync: deasync,
|
|
53
|
-
dir: dir,
|
|
54
|
-
expand: function (pattern, options) {
|
|
55
|
-
return dir('.').expand(pattern, options);
|
|
56
|
-
},
|
|
57
|
-
isDir: function (dirpath) {
|
|
58
|
-
try {
|
|
59
|
-
return fs.statSync(dirpath).isDirectory();
|
|
60
|
-
} catch(err) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
file: file,
|
|
65
|
-
isFile: function (dirpath) {
|
|
66
|
-
try {
|
|
67
|
-
return fs.statSync(dirpath).isFile();
|
|
68
|
-
} catch(err) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
tools: _,
|
|
73
|
-
copy: function () {
|
|
74
|
-
dir.copy.apply(this, arguments);
|
|
75
|
-
return nitro;
|
|
76
|
-
},
|
|
77
|
-
symlink: function (_path, target, type) {
|
|
78
|
-
var dirpath = joinPaths.root( _path.replace(/\/[^\/]+$/, '') );
|
|
79
|
-
if( !dir.exists(dirpath) ) {
|
|
80
|
-
dir.create(dirpath);
|
|
81
|
-
}
|
|
82
|
-
fs.symlinkSync( target, joinPaths.root(_path), type);
|
|
83
|
-
return nitro;
|
|
84
|
-
},
|
|
85
|
-
load: function (pattern, options) {
|
|
86
|
-
return dir.load('.', pattern, options);
|
|
87
|
-
},
|
|
88
|
-
// addPreset: returnNitro( processors.addPreset ),
|
|
89
|
-
// loadProcessors: returnNitro( processors.loadPresets ),
|
|
90
|
-
dirExpand: dirExpand,
|
|
91
|
-
require: autoRequire,
|
|
92
|
-
import: function (dirpath, filter) {
|
|
93
|
-
if( !dir.exists(dirpath) ) {
|
|
94
|
-
console.error('directory ' + color.yellow(dirpath) + ' does not exists');
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
dir(dirpath).load( filter || ( filter === false ? '*.js' : '{,**/}*.js' ) )
|
|
99
|
-
.each(function (f) {
|
|
100
|
-
var fullpath = joinPaths.root( f.cwd, f.path );
|
|
101
|
-
if( fullpath === __filename ) return;
|
|
102
|
-
require( fullpath )(nitro);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
return nitro;
|
|
106
|
-
},
|
|
107
|
-
registerProcessor: returnNitro(processors.register),
|
|
108
|
-
task: tasks,
|
|
109
|
-
template: require('trisquel'),
|
|
110
|
-
libs2html: dir.libs2html,
|
|
111
|
-
watch: require('./watch'),
|
|
112
|
-
livereload: function (dirpath, options) {
|
|
113
|
-
options = options ? _.copy(options) : {};
|
|
114
|
-
|
|
115
|
-
if( options.highlight ) {
|
|
116
|
-
options.highlight = autoRequire('cardinal').highlight;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
livereload(options.server || server(__dirname + '/livereload', { port: options.port || 12345, log: false }), dirpath, options);
|
|
120
|
-
},
|
|
121
|
-
parseJSON: function (json) {
|
|
122
|
-
return JSON.parse(json);
|
|
123
|
-
},
|
|
124
|
-
parseYAML: function (yaml, options) {
|
|
125
|
-
options = options || {};
|
|
126
|
-
return YAML.safeLoad(yaml, {
|
|
127
|
-
filename: options.filename,
|
|
128
|
-
schema: options.schema,
|
|
129
|
-
json: options.json,
|
|
130
|
-
onWarning: function () {
|
|
131
|
-
console.log.apply(console, ['YAML error'].concat(arguments));
|
|
132
|
-
if( options.onWarning instanceof Function ) options.onWarning.apply(this, arguments);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
stringify: function (data, format, options) {
|
|
137
|
-
format = format || 'json';
|
|
138
|
-
options = options || {};
|
|
139
|
-
|
|
140
|
-
if( format === 'json' ) {
|
|
141
|
-
return JSON.stringify(data, null, options.indentBy || '\t' );
|
|
142
|
-
} else if( format === 'yaml' ) {
|
|
143
|
-
return YAML.safeDump(data);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
throw new Error('Stringify to ' + format + ' format not supported.');
|
|
147
|
-
},
|
|
148
|
-
run: function (taskList) {
|
|
149
|
-
if( taskList && process.argv.length < 3 ) {
|
|
150
|
-
console.error('needs at least 1 argument');
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return tasks.run( taskList || [].slice.call(process.argv, 2));
|
|
155
|
-
},
|
|
156
|
-
server: server
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
nitro.package = require('./package')(nitro);
|
|
160
|
-
|
|
161
|
-
module.exports = nitro;
|
package/lib/package.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = function (nitro) {
|
|
4
|
-
|
|
5
|
-
var _ = nitro.tools,
|
|
6
|
-
fs = require('fs'),
|
|
7
|
-
joinPaths = require('./join-paths'),
|
|
8
|
-
defaultDirs = {
|
|
9
|
-
npm: 'node_modules',
|
|
10
|
-
bower: 'bower_components'
|
|
11
|
-
},
|
|
12
|
-
pkgFiles = {
|
|
13
|
-
npm: ['package.json'],
|
|
14
|
-
bower: ['bower.json', '.bower.json']
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
function pkgFileName (pkgName, cwd) {
|
|
18
|
-
cwd = cwd || '.';
|
|
19
|
-
|
|
20
|
-
return ( pkgFiles[pkgName] || [] ).find(function (filename) {
|
|
21
|
-
return nitro.file.exists( joinPaths(cwd, filename) );
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function readPkg (pkgName, cwd) {
|
|
26
|
-
var filename = pkgFileName(pkgName, cwd);
|
|
27
|
-
|
|
28
|
-
if( !filename ) {
|
|
29
|
-
throw new Error(filename + ' not found in ' + joinPaths(cwd || '.') + ' for pkg: ' + pkgName);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return nitro.file.readJSON( joinPaths(cwd || '.', filename) );
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Dependencies
|
|
36
|
-
|
|
37
|
-
function getDependenciesDir (pkgName) {
|
|
38
|
-
try {
|
|
39
|
-
return JSON.parse( fs.readFileSync( '.' + pkgName + 'rc', { encoding: 'utf8' }) ).directory;
|
|
40
|
-
} catch (err) {
|
|
41
|
-
return defaultDirs[pkgName];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function Dependencies ( pkg, type ) {
|
|
46
|
-
var dependenciesKey = type ? ( type + 'Dependencies' ) : 'dependencies';
|
|
47
|
-
this.pkg = pkg;
|
|
48
|
-
|
|
49
|
-
this.dependencies = pkg.data[dependenciesKey];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
Dependencies.prototype.getList = function () {
|
|
53
|
-
return this.dependencies;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
Dependencies.prototype.each = function (handler) {
|
|
57
|
-
for( var key in this.dependencies ) {
|
|
58
|
-
handler(key, this.dependencies[key]);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return this;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
function expandDependencies (dependencies, options, found, map) {
|
|
65
|
-
options = options || {};
|
|
66
|
-
found = found || [];
|
|
67
|
-
map = map || {};
|
|
68
|
-
|
|
69
|
-
var meta = dependencies.pkg.meta,
|
|
70
|
-
filter = options.filter || function () { return true; };
|
|
71
|
-
|
|
72
|
-
dependencies.each(function (dependence, version) {
|
|
73
|
-
if( map[dependence] || !filter(dependence, version) ) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
map[dependence] = true;
|
|
77
|
-
|
|
78
|
-
var pkg = readPkg(meta.name, joinPaths(meta.dependenciesdir, dependence) ),
|
|
79
|
-
dependencedir = joinPaths( meta.dependenciesdir, dependence ),
|
|
80
|
-
pkgMain = dependencies.pkg.data.overrides && dependencies.pkg.data.overrides[dependence] && dependencies.pkg.data.overrides[dependence].main || pkg.main;
|
|
81
|
-
|
|
82
|
-
_.extend(pkg, (dependencies.pkg.data.extend || {})[dependence] || {});
|
|
83
|
-
_.merge(pkg, (dependencies.pkg.data.merge || {})[dependence] || {});
|
|
84
|
-
|
|
85
|
-
if( pkgMain ) {
|
|
86
|
-
found = found.concat( nitro.dir( dependencedir ).expand(pkgMain).map(function (filename) {
|
|
87
|
-
return joinPaths(dependence, filename);
|
|
88
|
-
}) );
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if( options.inCascade && pkg.dependencies ) {
|
|
92
|
-
var cwd;
|
|
93
|
-
if( nitro.dir.exists( joinPaths(dependencedir, meta.dependenciesdir) ) ) {
|
|
94
|
-
cwd = process.cwd();
|
|
95
|
-
process.chdir( joinPaths.root(dependencedir) );
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
found = found.concat(
|
|
99
|
-
expandDependencies( new Package(pkg, meta).dependencies(), options, [], map )
|
|
100
|
-
.map(function (filepath) {
|
|
101
|
-
return cwd ? joinPaths(dependencedir, filepath) : filepath;
|
|
102
|
-
})
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
if( cwd ) {
|
|
106
|
-
process.chdir( cwd );
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
return found;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function inDependenceList (dependenceName) {
|
|
115
|
-
return function (matcher) {
|
|
116
|
-
return matcher instanceof RegExp ? matcher.test(dependenceName) : dependenceName === matcher;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
Dependencies.prototype.expand = function (inCascade, options) {
|
|
121
|
-
|
|
122
|
-
if( typeof inCascade === 'boolean' ) options = options ||{ inCascade: inCascade };
|
|
123
|
-
else if( typeof options === 'string' ) options = { filter: [inCascade] };
|
|
124
|
-
else if( options instanceof Array ) options = { filter: inCascade };
|
|
125
|
-
else options = inCascade || {};
|
|
126
|
-
|
|
127
|
-
options.filter = options.filter || (options.only && function (dependenceName) {
|
|
128
|
-
return options.only.some( inDependenceList(dependenceName) );
|
|
129
|
-
}) || (options.exclude && function (dependenceName) {
|
|
130
|
-
return !options.exclude.some( inDependenceList(dependenceName) );
|
|
131
|
-
}) || undefined;
|
|
132
|
-
|
|
133
|
-
return expandDependencies( this, options );
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
Dependencies.prototype.copy = function (dest, options) {
|
|
137
|
-
var dependenciesdir = this.pkg.meta.dependenciesdir;
|
|
138
|
-
|
|
139
|
-
options = options || {};
|
|
140
|
-
if( options.expand === undefined ) {
|
|
141
|
-
options.expand = true;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
expandDependencies( this, options ).forEach(function (filepath) {
|
|
145
|
-
var filepathFull = joinPaths(dependenciesdir, filepath);
|
|
146
|
-
|
|
147
|
-
if( nitro.isFile(filepathFull) ) {
|
|
148
|
-
nitro.file.copy( filepathFull, joinPaths(dest, options.expand ? filepath : nitro.file.parsePath(filepath).filename ) );
|
|
149
|
-
} else if( nitro.isDir(filepathFull) ) {
|
|
150
|
-
nitro.dir.copy( filepathFull, joinPaths( dest, filepath ) );
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
return this;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// Package
|
|
157
|
-
|
|
158
|
-
function Package (data, meta) {
|
|
159
|
-
this.data = data;
|
|
160
|
-
this.meta = meta;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
Package.prototype.dependencies = function (type) {
|
|
164
|
-
return new Dependencies(this, type);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
var partIndex = {
|
|
168
|
-
mayor: 0,
|
|
169
|
-
minor: 1,
|
|
170
|
-
build: 2,
|
|
171
|
-
patch: 2
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
Package.prototype.version = function (part) {
|
|
175
|
-
if( part ) {
|
|
176
|
-
return this.data.version.split('.')[partIndex[part]];
|
|
177
|
-
}
|
|
178
|
-
return this.data.version;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
Package.prototype.setVersion = function (version) {
|
|
182
|
-
var filename = pkgFileName(this.meta.name);
|
|
183
|
-
this.data.version = version;
|
|
184
|
-
nitro.file.writeJSON(filename, this.data, ' ');
|
|
185
|
-
return this;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
Package.prototype.increaseVersion = function (part) {
|
|
189
|
-
part = part || 'build';
|
|
190
|
-
|
|
191
|
-
if( part ) {
|
|
192
|
-
var versionParts = this.data.version.split('.');
|
|
193
|
-
versionParts[partIndex[part]] = Number(versionParts[partIndex[part]]) + 1;
|
|
194
|
-
this.setVersion( versionParts.join('.') );
|
|
195
|
-
}
|
|
196
|
-
return this;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
function getPackage (pkgName, dependenciesdir ) {
|
|
200
|
-
pkgName = pkgName || 'npm';
|
|
201
|
-
|
|
202
|
-
return new Package(
|
|
203
|
-
readPkg(pkgName), {
|
|
204
|
-
name: pkgName,
|
|
205
|
-
dependenciesdir: dependenciesdir || getDependenciesDir(pkgName)
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return getPackage;
|
|
210
|
-
|
|
211
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = function (nitro) {
|
|
4
|
-
|
|
5
|
-
var autoprefixer = nitro.require('autoprefixer');
|
|
6
|
-
|
|
7
|
-
return function (list, options) {
|
|
8
|
-
return list.process('postcss', { plugins: [ autoprefixer( require('./postcss/autoprefixer-options')(options) ) ] });
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
};
|
package/lib/presets/babel.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = function (nitro) {
|
|
4
|
-
|
|
5
|
-
var babel = nitro.require('babel-core'),
|
|
6
|
-
// presetsLoaded = { 'es2015': true };
|
|
7
|
-
presetsLoaded = {};
|
|
8
|
-
|
|
9
|
-
// nitro.require('babel-preset-es2015');
|
|
10
|
-
|
|
11
|
-
return function (list, options) {
|
|
12
|
-
options = options || {};
|
|
13
|
-
|
|
14
|
-
if( options.presets ) {
|
|
15
|
-
options.presets.forEach(function (preset) {
|
|
16
|
-
if( !presetsLoaded[preset] ) {
|
|
17
|
-
nitro.require('babel-preset-' + preset);
|
|
18
|
-
presetsLoaded[preset] = true;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
list.each(function (f) {
|
|
24
|
-
var result = babel.transform( f.src , options);
|
|
25
|
-
f.src = result.code ;
|
|
26
|
-
f.map = result.map ;
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return list;
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
};
|