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.
Files changed (306) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +11 -259
  3. package/dist/_chunks/app.mjs +19797 -0
  4. package/dist/_chunks/build.mjs +84 -0
  5. package/dist/_chunks/build2.mjs +318 -0
  6. package/dist/_chunks/build3.mjs +6452 -0
  7. package/dist/_chunks/detect-acorn.mjs +503 -0
  8. package/dist/_chunks/index.mjs +22242 -0
  9. package/dist/_chunks/index2.mjs +297 -0
  10. package/dist/_chunks/index3.mjs +1058 -0
  11. package/dist/_chunks/index4.mjs +1206 -0
  12. package/dist/_chunks/info.mjs +11157 -0
  13. package/dist/_chunks/json5.mjs +68 -0
  14. package/dist/_chunks/jsonc.mjs +51 -0
  15. package/dist/_chunks/pathe.M-eThtNZ.mjs +204 -0
  16. package/dist/_chunks/plugin.mjs +960 -0
  17. package/dist/_chunks/server.mjs +254 -0
  18. package/dist/_chunks/snapshot.mjs +284 -0
  19. package/dist/_chunks/toml.mjs +259 -0
  20. package/dist/_chunks/yaml.mjs +86 -0
  21. package/dist/cli/build.mjs +54 -0
  22. package/dist/cli/common.mjs +13 -0
  23. package/dist/cli/dev.mjs +95 -0
  24. package/dist/cli/index.d.mts +1 -0
  25. package/dist/cli/index.mjs +477 -0
  26. package/dist/cli/index2.mjs +17 -0
  27. package/dist/cli/list.mjs +34 -0
  28. package/dist/cli/prepare.mjs +24 -0
  29. package/dist/cli/run.mjs +60 -0
  30. package/dist/index.d.mts +52 -0
  31. package/dist/index.mjs +55 -0
  32. package/dist/node_modules/@poppinss/colors/build/index.js +169 -0
  33. package/dist/node_modules/@poppinss/colors/package.json +116 -0
  34. package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
  35. package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
  36. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +717 -0
  37. package/dist/node_modules/@poppinss/dumper/package.json +122 -0
  38. package/dist/node_modules/@poppinss/exception/build/index.js +63 -0
  39. package/dist/node_modules/@poppinss/exception/package.json +106 -0
  40. package/dist/node_modules/@sindresorhus/is/distribution/index.js +1313 -0
  41. package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
  42. package/dist/node_modules/@sindresorhus/is/package.json +81 -0
  43. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
  44. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
  45. package/dist/node_modules/@speed-highlight/core/package.json +90 -0
  46. package/dist/node_modules/cookie/dist/index.js +239 -0
  47. package/dist/node_modules/cookie/package.json +42 -0
  48. package/dist/node_modules/croner/dist/croner.js +1 -0
  49. package/dist/node_modules/croner/package.json +63 -0
  50. package/dist/node_modules/defu/dist/defu.mjs +69 -0
  51. package/dist/node_modules/defu/package.json +43 -0
  52. package/dist/node_modules/destr/dist/index.mjs +72 -0
  53. package/dist/node_modules/destr/package.json +47 -0
  54. package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
  55. package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
  56. package/dist/node_modules/error-stack-parser-es/package.json +83 -0
  57. package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
  58. package/dist/node_modules/get-port-please/package.json +39 -0
  59. package/dist/node_modules/hookable/dist/index.mjs +290 -0
  60. package/dist/node_modules/hookable/package.json +49 -0
  61. package/dist/node_modules/kleur/index.js +110 -0
  62. package/dist/node_modules/kleur/index.mjs +110 -0
  63. package/dist/node_modules/kleur/package.json +51 -0
  64. package/dist/node_modules/klona/dist/index.mjs +81 -0
  65. package/dist/node_modules/klona/full/index.mjs +53 -0
  66. package/dist/node_modules/klona/package.json +74 -0
  67. package/dist/node_modules/scule/dist/index.mjs +80 -0
  68. package/dist/node_modules/scule/package.json +43 -0
  69. package/dist/node_modules/source-map/lib/array-set.js +100 -0
  70. package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
  71. package/dist/node_modules/source-map/lib/base64.js +19 -0
  72. package/dist/node_modules/source-map/lib/binary-search.js +113 -0
  73. package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
  74. package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
  75. package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
  76. package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
  77. package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
  78. package/dist/node_modules/source-map/lib/source-node.js +430 -0
  79. package/dist/node_modules/source-map/lib/url.js +13 -0
  80. package/dist/node_modules/source-map/lib/util.js +444 -0
  81. package/dist/node_modules/source-map/lib/wasm.js +138 -0
  82. package/dist/node_modules/source-map/package.json +79 -0
  83. package/dist/node_modules/source-map/source-map.js +10 -0
  84. package/dist/node_modules/std-env/dist/index.mjs +1 -0
  85. package/dist/node_modules/std-env/package.json +46 -0
  86. package/dist/node_modules/supports-color/index.js +202 -0
  87. package/dist/node_modules/supports-color/package.json +64 -0
  88. package/dist/node_modules/ufo/dist/index.mjs +638 -0
  89. package/dist/node_modules/ufo/package.json +47 -0
  90. package/dist/node_modules/unctx/dist/index.mjs +131 -0
  91. package/dist/node_modules/unctx/package.json +67 -0
  92. package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +42 -0
  93. package/dist/node_modules/youch/build/chunk-4XB2BYKC.js +85 -0
  94. package/dist/node_modules/youch/build/chunk-4YEN7HVQ.js +61 -0
  95. package/dist/node_modules/youch/build/chunk-EUJBVOYB.js +83 -0
  96. package/dist/node_modules/youch/build/chunk-HFSXRSKS.js +85 -0
  97. package/dist/node_modules/youch/build/chunk-JAN2TFI2.js +222 -0
  98. package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +6 -0
  99. package/dist/node_modules/youch/build/chunk-PINJDICN.js +72 -0
  100. package/dist/node_modules/youch/build/chunk-PUHGL6HA.js +41 -0
  101. package/dist/node_modules/youch/build/chunk-VE4LENUR.js +45 -0
  102. package/dist/node_modules/youch/build/index.js +352 -0
  103. package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
  104. package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
  105. package/dist/node_modules/youch/build/public/error_info/style.css +144 -0
  106. package/dist/node_modules/youch/build/public/error_stack/script.js +74 -0
  107. package/dist/node_modules/youch/build/public/error_stack/style.css +220 -0
  108. package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
  109. package/dist/node_modules/youch/build/public/header/script.js +16 -0
  110. package/dist/node_modules/youch/build/public/header/style.css +56 -0
  111. package/dist/node_modules/youch/build/public/layout/script.js +20 -0
  112. package/dist/node_modules/youch/build/public/layout/style.css +431 -0
  113. package/dist/node_modules/youch/package.json +133 -0
  114. package/dist/node_modules/youch-core/build/index.js +316 -0
  115. package/dist/node_modules/youch-core/package.json +124 -0
  116. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
  117. package/dist/presets/_nitro/runtime/nitro-dev.mjs +62 -0
  118. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +3 -0
  119. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +18 -0
  120. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
  121. package/dist/presets/_nitro/runtime/service-worker.mjs +21 -0
  122. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
  123. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +13 -0
  124. package/dist/presets/aws-lambda/runtime/_utils.d.mts +18 -0
  125. package/dist/presets/aws-lambda/runtime/_utils.mjs +102 -0
  126. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +3 -0
  127. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +33 -0
  128. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +3 -0
  129. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
  130. package/dist/presets/azure/runtime/_utils.d.mts +2 -0
  131. package/dist/presets/azure/runtime/_utils.mjs +50 -0
  132. package/dist/presets/azure/runtime/azure-swa.d.mts +5 -0
  133. package/dist/presets/azure/runtime/azure-swa.mjs +28 -0
  134. package/dist/presets/bun/runtime/bun.d.mts +1 -0
  135. package/dist/presets/bun/runtime/bun.mjs +27 -0
  136. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +13 -0
  137. package/dist/presets/cloudflare/runtime/_module-handler.mjs +93 -0
  138. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +19 -0
  139. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +74 -0
  140. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +9 -0
  141. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +20 -0
  142. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +20 -0
  143. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +47 -0
  144. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +3 -0
  145. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +89 -0
  146. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
  147. package/dist/presets/deno/runtime/deno-deploy.mjs +17 -0
  148. package/dist/presets/deno/runtime/deno-server.d.mts +6 -0
  149. package/dist/presets/deno/runtime/deno-server.mjs +59 -0
  150. package/dist/presets/netlify/runtime/netlify-edge.d.mts +3 -0
  151. package/dist/presets/netlify/runtime/netlify-edge.mjs +17 -0
  152. package/dist/presets/netlify/runtime/netlify.d.mts +3 -0
  153. package/dist/presets/netlify/runtime/netlify.mjs +24 -0
  154. package/dist/presets/node/runtime/node-cluster.d.mts +1 -0
  155. package/dist/presets/node/runtime/node-cluster.mjs +58 -0
  156. package/dist/presets/node/runtime/node-middleware.d.mts +4 -0
  157. package/dist/presets/node/runtime/node-middleware.mjs +14 -0
  158. package/dist/presets/node/runtime/node-server.d.mts +3 -0
  159. package/dist/presets/node/runtime/node-server.mjs +44 -0
  160. package/dist/presets/standard/runtime/server.d.mts +5 -0
  161. package/dist/presets/standard/runtime/server.mjs +6 -0
  162. package/dist/presets/stormkit/runtime/stormkit.d.mts +21 -0
  163. package/dist/presets/stormkit/runtime/stormkit.mjs +28 -0
  164. package/dist/presets/vercel/runtime/vercel.d.mts +8 -0
  165. package/dist/presets/vercel/runtime/vercel.mjs +17 -0
  166. package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -0
  167. package/dist/presets/winterjs/runtime/winterjs.mjs +87 -0
  168. package/dist/presets/zeabur/runtime/zeabur.d.mts +3 -0
  169. package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
  170. package/dist/presets.mjs +2460 -0
  171. package/dist/runtime/index.d.mts +11 -0
  172. package/dist/runtime/index.mjs +17 -0
  173. package/dist/runtime/internal/app.d.mts +2 -0
  174. package/dist/runtime/internal/app.mjs +153 -0
  175. package/dist/runtime/internal/cache.d.mts +7 -0
  176. package/dist/runtime/internal/cache.mjs +236 -0
  177. package/dist/runtime/internal/context.d.mts +12 -0
  178. package/dist/runtime/internal/context.mjs +17 -0
  179. package/dist/runtime/internal/database.d.mts +2 -0
  180. package/dist/runtime/internal/database.mjs +14 -0
  181. package/dist/runtime/internal/debug.d.mts +2 -0
  182. package/dist/runtime/internal/debug.mjs +5 -0
  183. package/dist/runtime/internal/empty.d.mts +0 -0
  184. package/dist/runtime/internal/empty.mjs +0 -0
  185. package/dist/runtime/internal/error/dev.d.mts +9 -0
  186. package/dist/runtime/internal/error/dev.mjs +122 -0
  187. package/dist/runtime/internal/error/prod.d.mts +8 -0
  188. package/dist/runtime/internal/error/prod.mjs +62 -0
  189. package/dist/runtime/internal/error/utils.d.mts +8 -0
  190. package/dist/runtime/internal/error/utils.mjs +3 -0
  191. package/dist/runtime/internal/index.d.mts +3 -0
  192. package/dist/runtime/internal/index.mjs +3 -0
  193. package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +16 -0
  194. package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +213 -0
  195. package/dist/runtime/internal/meta.d.mts +2 -0
  196. package/dist/runtime/internal/meta.mjs +3 -0
  197. package/dist/runtime/internal/plugin.d.mts +3 -0
  198. package/dist/runtime/internal/plugin.mjs +4 -0
  199. package/dist/runtime/internal/renderer.d.mts +3 -0
  200. package/dist/runtime/internal/renderer.mjs +36 -0
  201. package/dist/runtime/internal/route-rules.d.mts +8 -0
  202. package/dist/runtime/internal/route-rules.mjs +62 -0
  203. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
  204. package/dist/runtime/internal/routes/dev-tasks.mjs +23 -0
  205. package/dist/runtime/internal/routes/openapi.d.mts +3 -0
  206. package/dist/runtime/internal/routes/openapi.mjs +100 -0
  207. package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
  208. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
  209. package/dist/runtime/internal/routes/renderer-template.dev.mjs +21 -0
  210. package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
  211. package/dist/runtime/internal/routes/scalar.d.mts +3 -0
  212. package/dist/runtime/internal/routes/scalar.mjs +194 -0
  213. package/dist/runtime/internal/routes/swagger.d.mts +3 -0
  214. package/dist/runtime/internal/routes/swagger.mjs +44 -0
  215. package/dist/runtime/internal/runtime-config.d.mts +9 -0
  216. package/dist/runtime/internal/runtime-config.mjs +49 -0
  217. package/dist/runtime/internal/shutdown.d.mts +9 -0
  218. package/dist/runtime/internal/shutdown.mjs +34 -0
  219. package/dist/runtime/internal/static.d.mts +3 -0
  220. package/dist/runtime/internal/static.mjs +77 -0
  221. package/dist/runtime/internal/storage.d.mts +2 -0
  222. package/dist/runtime/internal/storage.mjs +6 -0
  223. package/dist/runtime/internal/task.d.mts +17 -0
  224. package/dist/runtime/internal/task.mjs +73 -0
  225. package/dist/runtime/internal/utils.d.mts +1 -0
  226. package/dist/runtime/internal/utils.mjs +15 -0
  227. package/dist/runtime/internal/vite/dev-entry.d.mts +1 -0
  228. package/dist/runtime/internal/vite/dev-entry.mjs +6 -0
  229. package/dist/runtime/internal/vite/dev-worker.d.mts +1 -0
  230. package/dist/runtime/internal/vite/dev-worker.mjs +362 -0
  231. package/dist/runtime/internal/vite/prod-setup.d.mts +4 -0
  232. package/dist/runtime/internal/vite/prod-setup.mjs +55 -0
  233. package/dist/runtime/internal/vite/ssr-renderer.d.mts +4 -0
  234. package/dist/runtime/internal/vite/ssr-renderer.mjs +4 -0
  235. package/dist/types/index.d.mts +2810 -0
  236. package/dist/types/index.mjs +1 -0
  237. package/dist/vite.d.mts +59 -0
  238. package/dist/vite.mjs +68 -0
  239. package/lib/config.d.mts +9 -0
  240. package/lib/config.mjs +5 -0
  241. package/lib/deps/h3.d.mts +1 -0
  242. package/lib/deps/h3.mjs +1 -0
  243. package/lib/deps/ofetch.mjs +1 -0
  244. package/lib/deps/ofetch.mts +1 -0
  245. package/lib/meta.d.mts +5 -0
  246. package/lib/meta.mjs +21 -0
  247. package/lib/runtime-meta.d.mts +5 -0
  248. package/lib/runtime-meta.mjs +38 -0
  249. package/package.json +190 -36
  250. package/.editorconfig +0 -12
  251. package/.eslintrc.js +0 -34
  252. package/.travis.yml +0 -7
  253. package/Dockerfile +0 -12
  254. package/Makefile +0 -37
  255. package/bin/nitro +0 -55
  256. package/lib/auto-require.js +0 -44
  257. package/lib/class-file.js +0 -105
  258. package/lib/class-files.js +0 -212
  259. package/lib/color.js +0 -89
  260. package/lib/cwd.js +0 -27
  261. package/lib/dir-expand.js +0 -80
  262. package/lib/dir.js +0 -130
  263. package/lib/file.js +0 -80
  264. package/lib/join-paths.js +0 -60
  265. package/lib/livereload/livereload.js +0 -55
  266. package/lib/livereload.js +0 -86
  267. package/lib/nitro.js +0 -161
  268. package/lib/package.js +0 -211
  269. package/lib/presets/autoprefixer.js +0 -11
  270. package/lib/presets/babel.js +0 -33
  271. package/lib/presets/browserify.js +0 -106
  272. package/lib/presets/coffee-script.js +0 -29
  273. package/lib/presets/cssnano.js +0 -11
  274. package/lib/presets/eslint.js +0 -67
  275. package/lib/presets/jshint.js +0 -51
  276. package/lib/presets/less.js +0 -45
  277. package/lib/presets/log.js +0 -11
  278. package/lib/presets/ng-annotate.js +0 -34
  279. package/lib/presets/noop.js +0 -7
  280. package/lib/presets/postcss/auto-postcss.js +0 -46
  281. package/lib/presets/postcss/autoprefixer-options.js +0 -9
  282. package/lib/presets/postcss.js +0 -40
  283. package/lib/presets/rollup.js +0 -56
  284. package/lib/presets/sass.js +0 -64
  285. package/lib/presets/sitemap.js +0 -101
  286. package/lib/presets/sitemap.xml +0 -12
  287. package/lib/presets/svg-symbols.js +0 -22
  288. package/lib/presets/svgo.js +0 -21
  289. package/lib/presets/uglify.js +0 -72
  290. package/lib/presets/webpack.js +0 -66
  291. package/lib/processors.js +0 -84
  292. package/lib/promisify.js +0 -16
  293. package/lib/server.js +0 -224
  294. package/lib/tasks.js +0 -114
  295. package/lib/watch.js +0 -81
  296. package/test.js +0 -59
  297. package/tests/cwd-tests.js +0 -25
  298. package/tests/dir-tests.js +0 -80
  299. package/tests/dummy/dummy.coffee +0 -7
  300. package/tests/dummy/dummy.js +0 -8
  301. package/tests/dummy/dummy.less +0 -6
  302. package/tests/dummy/dummy.sass +0 -5
  303. package/tests/file-tests.js +0 -17
  304. package/tests/join-paths-tests.js +0 -86
  305. package/tests/tasks-tests.js +0 -65
  306. package/wercker.yml +0 -25
@@ -1,44 +0,0 @@
1
-
2
- var dir = require('./dir'),
3
- file = require('./file'),
4
- color = require('./color'),
5
- joinPaths = require('./join-paths'),
6
- deasync = require('deasync'),
7
- execSH = require('child_process').execSync || deasync( require('child_process').exec );
8
-
9
- module.exports = function requireLibs (requirements) {
10
- if( typeof requirements === 'string' ) {
11
- requireLibs([requirements]);
12
- return require(requirements.split('@')[0]);
13
- }
14
-
15
- var versions = require('../package').autoRequire || {};
16
-
17
- requirements.forEach(function (libName) {
18
- var version = versions[libName],
19
- dirpath = joinPaths.root('node_modules', libName),
20
- startTime;
21
- if( /@/.test(libName) ) {
22
- libName = libName.split('@');
23
- version = libName[1];
24
- libName = libName[0];
25
- }
26
- if( !dir.exists( dirpath ) ) {
27
- console.log(color.magenta('installing'), color.yellow(libName) + color.cyan( version ? ( '@' + version ) : '' ), 'on-demand' );
28
- startTime = Date.now();
29
- execSH('npm install ' + libName + ( version ? ( '@' + version ) : '' ) );
30
- if( file.exists( [dirpath, 'package.json'] ) ) {
31
- console.log(color.green('\ninstalled ') + color.yellow(libName) + (version ? color.cyan('@' + file.readJSON( [dirpath, 'package.json'] ).version ) : '') + ' ' + ( Date.now() - startTime ) + 'ms\n' );
32
- }
33
- } else if( version && file.exists( [ dirpath, 'package.json' ] ) ) {
34
- if( file.readJSON( [dirpath, 'package.json'] ).version >= version.replace(/\.x/g, '') ) return;
35
-
36
- console.log(color.magenta('updating'), color.yellow(libName) + color.cyan('@' + version), 'on-demand' );
37
- startTime = Date.now();
38
- execSH('npm install ' + libName + '@' + version );
39
- if( file.exists( [dirpath, 'package.json'] ) ) {
40
- console.log(color.green('\nupdated ') + color.yellow(libName) + color.cyan('@' + file.readJSON( [dirpath, 'package.json'] ).version ) + ' ' + ( Date.now() - startTime ) + 'ms\n' );
41
- }
42
- }
43
- });
44
- };
package/lib/class-file.js DELETED
@@ -1,105 +0,0 @@
1
-
2
- 'use strict';
3
-
4
- var _ = require('nitro-tools'),
5
- joinPaths = require('./join-paths'),
6
- file = require('./file'),
7
- color = require('./color'),
8
- process_cwd = process.cwd();
9
-
10
- function File (filepath, src, map, list) {
11
-
12
- if( list ) this.list = list;
13
-
14
- this.__ = {};
15
-
16
- if( filepath ) this.path = filepath;
17
- if( src ) this.__.src = src;
18
- if( map ) this.__.map = map;
19
-
20
- }
21
-
22
- Object.defineProperty(File.prototype, 'path', {
23
- get: function () {
24
- return joinPaths( this.filepath || '.', this.filename );
25
- },
26
- set: function (filepath) {
27
- _.extend(this, file.parsePath(filepath) );
28
- }
29
- });
30
-
31
- Object.defineProperty(File.prototype, 'full_path', {
32
- get: function () {
33
- return joinPaths.root( this.cwd, this.path );
34
- }
35
- });
36
-
37
- Object.defineProperty(File.prototype, 'full_dir', {
38
- get: function () {
39
- return joinPaths.root( this.cwd, this.filepath );
40
- }
41
- });
42
-
43
- Object.defineProperty(File.prototype, 'src', {
44
- get: function () {
45
- if( this.__.src === undefined ) this.load();
46
- return this.__.src || '';
47
- },
48
- set: function (src) {
49
- this.__.src = src;
50
- }
51
- });
52
-
53
- Object.defineProperty(File.prototype, 'map', {
54
- get: function () {
55
- return this.__.map;
56
- },
57
- set: function (map) {
58
- this.__.map = typeof map === 'string' ? map : JSON.stringify(map);
59
- }
60
- });
61
-
62
- Object.defineProperty(File.prototype, 'cwd', {
63
- get: function () {
64
- return this.list && this.list.cwd || '.';
65
- }
66
- });
67
-
68
- ['src', 'path', 'map'].forEach(function (property) {
69
- var property_title_case = property[0].toUpperCase() + property.substr(1);
70
-
71
- File.prototype['get' + property_title_case] = function () {
72
- console.log( color.yellow('[WARN]') + 'File.prototype.get' + property_title_case + ' is deprecated, please ' + color.yellow('use File.prototype.' + property) + ' instead' );
73
- return this.src;
74
- };
75
- File.prototype['set' + property_title_case] = function (src) {
76
- console.log( color.yellow('[WARN]') + 'File.prototype.set' + property_title_case + ' is deprecated, please ' + color.yellow('use File.prototype.' + property) + ' instead' );
77
- this.src = src; return this;
78
- };
79
-
80
- });
81
-
82
- File.prototype.load = function (fpath) {
83
- if( fpath ) this.path = fpath;
84
-
85
- var cwd = this.cwd;
86
- cwd = /^\//.test(cwd) ? cwd : joinPaths(process_cwd, cwd);
87
-
88
- this.src = file.read( joinPaths(cwd, this.path ) );
89
-
90
- return this;
91
- };
92
-
93
- File.prototype.json = function () {
94
- return JSON.parse( this.src );
95
- };
96
-
97
- File.prototype.yaml = function () {
98
- return require('js-yaml').safeLoad( this.src );
99
- };
100
-
101
- File.prototype.clone = function (list) {
102
- return new File(this.path, this.src, this.map, list || this.list);
103
- };
104
-
105
- module.exports = File;
@@ -1,212 +0,0 @@
1
-
2
- 'use strict';
3
-
4
- var _ = require('nitro-tools'),
5
- joinPaths = require('./join-paths'),
6
- mmatch = require('minimatch'),
7
- Minimatch = mmatch.Minimatch,
8
- file = require('./file'),
9
- color = require('./color'),
10
- // dirExpand = require('./dir-expand'),
11
- File = require('./class-file'),
12
- noop = function (value) { return value; },
13
- // noFilter = function () { return true; },
14
- arrPush = Array.prototype.push;
15
-
16
- function Files (files_list, options) {
17
- options = _.copy(options || {});
18
- this.cwd = options.cwd || '.';
19
-
20
- // var list = this;
21
-
22
- if( options.srcMap !== undefined ) {
23
- options.sourceMap = options.srcMap;
24
- }
25
-
26
- this.options = options;
27
-
28
- function FilesFile () {
29
- File.apply(this, arguments);
30
- }
31
-
32
- FilesFile.prototype = new File;
33
- FilesFile.prototype.constructor = FilesFile;
34
- FilesFile.prototype.list = this;
35
-
36
- this.File = FilesFile;
37
-
38
- arrPush.apply(this, files_list.map(function (filepath) {
39
- return filepath instanceof File ? filepath : new FilesFile( filepath );
40
- // return new File( filepath, null, null, list );
41
- }));
42
- }
43
-
44
- // function filterPattern (pattern) {
45
- // return mmatch.filter(pattern);
46
- // }
47
- //
48
- // function getFileSrc (f) {
49
- // return f.src;
50
- // }
51
- //
52
- // function filterListByPattern (list, pattern) {
53
- // var matchPattern = filterPattern(pattern);
54
- //
55
- // return [].filter.call(list, function (f) {
56
- // return matchPattern(f.path);
57
- // });
58
- // }
59
-
60
- Files.prototype = new Array;
61
- Files.prototype.constructor = Files;
62
-
63
- function allowAll () {
64
- return true;
65
- }
66
-
67
- Files.prototype.each = function (filterList, iteratee) {
68
-
69
- if( !filterList ) throw new Error('.each(...) expects at least 1 parameter');
70
-
71
- if( iteratee instanceof Function ) {
72
- filterList = filterList instanceof Function ? filterList : (function (mm) {
73
- return function (f) {
74
- return mm.match(f.path);
75
- };
76
- })(new Minimatch(filterList) );
77
- } else {
78
- // mapThis = iteratee;
79
- iteratee = filterList;
80
- filterList = allowAll;
81
- }
82
-
83
- this.forEach(function (f, i) {
84
- if( filterList(f) ) iteratee.call(f, f, i);
85
- });
86
-
87
- return this;
88
- };
89
-
90
- Files.prototype.log = function (title) {
91
- if( title ) {
92
- console.log( color.yellow(title) );
93
- }
94
-
95
- this.each(function (f) {
96
- console.log( f.path );
97
- });
98
-
99
- return this;
100
- };
101
-
102
- Files.prototype.add = function (files) {
103
- var list = this;
104
-
105
- (files && files.length ? files : [files]).forEach(function (f) {
106
- f.list = list;
107
- list.push(f);
108
- });
109
- return this;
110
- };
111
-
112
- Files.prototype.filter = function (filter) {
113
- var list = new Files([], Object.create(this.options) );
114
-
115
- this.each(filter, function (f) {
116
- list.push(f);
117
- });
118
-
119
- return list;
120
- };
121
-
122
- // Files.prototype.with = function (pattern, processor, is_collection) {
123
- // if( processor instanceof Function ) {
124
- // is_collection ? processor( this.filter(pattern) ) : this.filter(pattern).forEach(processor);
125
- // } else this.filter(pattern).process(processor);
126
- //
127
- // return this;
128
- // };
129
-
130
- Files.prototype.load = function (patterns, options) {
131
- // this.add( dirExpand(patterns, this.cwd) );
132
- this.add( new Files(patterns, options || {}) );
133
- return this;
134
- };
135
-
136
- Files.prototype.concat = function (items) {
137
- arrPush.apply(this, items);
138
- return this;
139
- };
140
-
141
- Files.prototype.new = function (list, options) {
142
- return new Files( list || [], options || Object.create(this.options) );
143
- };
144
-
145
- Files.prototype.clone = function (options) {
146
- var files = this;
147
- return new Files( this.map(function (f) {
148
- return new files.File(f.path, f.src, f.map);
149
- }), options || Object.create(this.options) );
150
- };
151
-
152
- Files.prototype.join = function (filter, filepath, options) {
153
- if( !filepath || ( typeof filepath === 'object' && filepath !== null ) ) {
154
- if( !filter ) {
155
- throw new Error('Files.join :: filepath path needs to be defined');
156
- }
157
- options = filepath;
158
- filepath = filter;
159
- }
160
-
161
- options = options || {};
162
-
163
- var sourceMap = ( options.sourceMap !== undefined ? options.sourceMap : this.options.sourceMap );
164
-
165
- if( sourceMap ) {
166
- var Concat = require('./auto-require')('concat-with-sourcemaps'),
167
- concat = new Concat(true, 'all.js', '\n');
168
-
169
- this.each(function (f) {
170
- concat.add( f.path, f.src, f.map );
171
- });
172
-
173
- return new Files([ new this.File( filepath, '' + concat.content, concat.sourceMap ) ], Object.create(this.options) );
174
- }
175
-
176
- return new Files([ new this.File( filepath, this.map(function (f) {
177
- return f.src;
178
- }, []).join( options.join_str || '\n' ) ) ], Object.create(this.options));
179
- };
180
-
181
- Files.prototype.write = function (dest, rename, options) {
182
- options = options || ( _.isObject(rename) ? rename : {} );
183
- rename = _.isFunction(rename) || noop;
184
-
185
- var sourceMap = this.options.sourceMap !== undefined ? this.options.sourceMap : options.sourceMap;
186
-
187
- this.forEach(function (f) {
188
- var filepath = rename( joinPaths(dest, f.path) ),
189
- sourceMapPath = f.map && ( sourceMap === 'inline' ? ('data:application\/json;charset=utf-8;base64,' + new Buffer(f.map || '').toString('base64') ) : ( f.filename + '.map' ) ),
190
- src = f.src + ( (f.map && sourceMap !== false) ? ( /\.js$/.test(f.path) ? `\n//# sourceMappingURL=${sourceMapPath}` : `\n/*# sourceMappingURL=${sourceMapPath} */` ) : '' );
191
-
192
- file.write( filepath, src );
193
- if( f.map && sourceMap !== 'inline' && sourceMap !== false ) {
194
- file.write( filepath + '.map' , f.map );
195
- }
196
- });
197
- return this;
198
- };
199
-
200
- Files.prototype.writeFile = function (destFile) {
201
- file.write( destFile, this.join( destFile.split('/').pop() )[0].src );
202
- return this;
203
- };
204
-
205
- Files.prototype.getSrc = function () {
206
- return this.reduce(function (src, f) {
207
- src += f.src;
208
- return src;
209
- }, '');
210
- };
211
-
212
- module.exports = Files;
package/lib/color.js DELETED
@@ -1,89 +0,0 @@
1
-
2
- // from: https://github.com/Marak/colors.js/blob/master/lib/colors.js
3
- // @TODO https://en.wikipedia.org/wiki/ANSI_escape_code
4
-
5
- // https://coderwall.com/p/yphywg/printing-colorful-text-in-terminal-when-run-node-js-script
6
- // function brightBlue (text) {
7
- // return '\x1b[1m' + '\x1b[34m' + text + '\x1b[0m';
8
- // }
9
-
10
- const ESC = '\u001b';
11
-
12
- var styles = {};
13
- var color = {};
14
-
15
- var codes = {
16
- reset: [0, 0],
17
-
18
- bold: [1, 22],
19
- dim: [2, 22],
20
- italic: [3, 23],
21
- underline: [4, 24],
22
- inverse: [7, 27],
23
- hidden: [8, 28],
24
- strikethrough: [9, 29],
25
-
26
- blackBright: [30, 39, true],
27
- redBright: [31, 39, true],
28
- greenBright: [32, 39, true],
29
- yellowBright: [33, 39, true],
30
- blueBright: [34, 39, true],
31
- magentaBright: [35, 39, true],
32
- cyanBright: [36, 39, true],
33
- whiteBright: [37, 39, true],
34
- grayBright: [90, 39, true],
35
- greyBright: [90, 39, true],
36
-
37
- black: [30, 39],
38
- red: [31, 39],
39
- green: [32, 39],
40
- yellow: [33, 39],
41
- blue: [34, 39],
42
- magenta: [35, 39],
43
- cyan: [36, 39],
44
- white: [37, 39],
45
- gray: [90, 39],
46
- grey: [90, 39],
47
-
48
- bgBlack: [40, 49],
49
- bgRed: [41, 49],
50
- bgGreen: [42, 49],
51
- bgYellow: [43, 49],
52
- bgBlue: [44, 49],
53
- bgMagenta: [45, 49],
54
- bgCyan: [46, 49],
55
- bgWhite: [47, 49],
56
-
57
- // legacy styles for colors pre v1.0.0
58
- blackBG: [40, 49],
59
- redBG: [41, 49],
60
- greenBG: [42, 49],
61
- yellowBG: [43, 49],
62
- blueBG: [44, 49],
63
- magentaBG: [45, 49],
64
- cyanBG: [46, 49],
65
- whiteBG: [47, 49]
66
-
67
- };
68
-
69
- Object.keys(codes).forEach(function (key) {
70
- var val = codes[key];
71
- var style = styles[key] = [];
72
- style.open = ESC + '[' + (val[2] ? '1;' : '') + val[0] + 'm';
73
- style.close = ESC + '[' + (val[2] ? '0;' : '') + val[1] + 'm';
74
- });
75
-
76
- Object.keys(styles).forEach(function (key) {
77
- if( !styles[key] ) throw new Error('missing color ' + key);
78
- var open = styles[key].open,
79
- close = styles[key].close;
80
- color[key] = function (text) {
81
- return open + text + close;
82
- };
83
-
84
- // String.prototype.__defineGetter__(key, function () {
85
- // return open + this + close;
86
- // });
87
- });
88
-
89
- module.exports = color;
package/lib/cwd.js DELETED
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- var joinPaths = require('./join-paths');
4
-
5
- function _runCwd (cwd, dir_path, cb) {
6
- var cwd_path = joinPaths.root(cwd, dir_path), result;
7
- process.chdir( cwd_path );
8
- result = cb(cwd_path);
9
- process.chdir(cwd);
10
- return result;
11
- }
12
-
13
- function runCwd (dirpath, cb) {
14
- if( !dirpath ) return process.cwd();
15
-
16
- var cwd = process.cwd();
17
-
18
- if( !cb ) return function (_cb) {
19
- _runCwd(cwd, dirpath, _cb);
20
- };
21
-
22
- return _runCwd( cwd, dirpath, cb );
23
- }
24
-
25
- // runCwd.process_dir = process.cwd();
26
-
27
- module.exports = runCwd;
package/lib/dir-expand.js DELETED
@@ -1,80 +0,0 @@
1
-
2
- var mmmatch = require('minimatch'),
3
- Minimatch = mmmatch.Minimatch,
4
- fs = require('fs'),
5
- joinPaths = require('./join-paths'),
6
- arrShift = Array.prototype.shift,
7
- mapPatterns = function (pattern) {
8
- return new Minimatch(pattern.replace(/^\.\//, ''));
9
- };
10
-
11
- function filePathMatch (filepath, mmatches) {
12
- return mmatches.reduce(function (matches, mm) {
13
- if( mm.negate ) return matches && mm.match(filepath);
14
- return matches || mm.match(filepath);
15
- }, false);
16
- }
17
-
18
- function _expandDir (cwd, dirpath, mmatches) {
19
- var files = [],
20
- directories = [];
21
-
22
- fs.readdirSync( joinPaths.root(cwd, dirpath) ).forEach(function (filename) {
23
- var filepath = joinPaths(dirpath, filename),
24
- stat = fs.statSync( joinPaths.root(cwd, filepath) );
25
-
26
- if( stat.isFile() && filePathMatch(filepath, mmatches) ) files.push(filepath);
27
- else if( stat.isDirectory() ) directories.push.apply(directories, _expandDir(cwd, filepath, mmatches) );
28
-
29
- });
30
-
31
- return files.concat(directories);
32
- }
33
-
34
- function orderFiles (files, mmatches) {
35
- var results = [], tmp = files.slice();
36
-
37
- mmatches.forEach(function (mm) {
38
- var pushFile = function (file) {
39
- if( mm.match(file) ) results.push(file);
40
- else tmp.push(file);
41
- };
42
-
43
- if( mm.negate ) results.splice(0, results.length).forEach(pushFile);
44
- else tmp.splice(0, tmp.length).forEach(pushFile);
45
- });
46
-
47
- return results;
48
- }
49
-
50
- function expandDir (/* patterns[, dirpath][, options][, done] */) {
51
-
52
- var patterns = arrShift.call(arguments),
53
- done = arrShift.call(arguments),
54
- dirpath = '',
55
- options = {};
56
-
57
- if( typeof done === 'string' ) {
58
- dirpath = done; done = arrShift.call(arguments);
59
- }
60
- if( typeof done === 'object' ) {
61
- options = done; done = arrShift.call(arguments);
62
- }
63
-
64
- var mmatches = (typeof patterns === 'string' ? [patterns] : patterns).map(mapPatterns),
65
- stat;
66
-
67
- try{
68
- stat = fs.statSync( joinPaths.root(options.cwd, dirpath) );
69
- } catch(err) {
70
- return [];
71
- }
72
-
73
- return orderFiles( (stat && stat.isDirectory()) ? _expandDir( joinPaths(options.cwd, dirpath), '', mmatches ) : [] , mmatches);
74
- }
75
-
76
- expandDir.filter = function (expandedList, globList) {
77
- return orderFiles( expandedList, (typeof globList === 'string' ? [globList] : globList).map(mapPatterns) );
78
- };
79
-
80
- module.exports = expandDir;
package/lib/dir.js DELETED
@@ -1,130 +0,0 @@
1
- 'use strict';
2
-
3
- var _ = require('nitro-tools'),
4
- fs = require('fs'),
5
- joinPaths = require('./join-paths'),
6
- deasync = require('deasync'),
7
- exec = deasync( require('child_process').exec ),
8
- mkdirp = require('mkdirp'),
9
- file = require('./file'),
10
- Files = require('./class-files'),
11
- dirExpand = require('./dir-expand');
12
-
13
- function Dir (dirpath) {
14
- this.dirpath = joinPaths.root(dirpath);
15
- }
16
-
17
- function dir (dirpath) {
18
- return new Dir(dirpath);
19
- }
20
-
21
- _.extend(dir, {
22
- create: function (dirpath) {
23
- mkdirp.sync( joinPaths.root(dirpath) );
24
- return dir;
25
- },
26
- exists: function (dirpath) {
27
- try {
28
- return fs.statSync( joinPaths.root(dirpath) );
29
- } catch(err) {
30
- return false;
31
- }
32
- },
33
- copy: function copyFiles (dirpath, globSrc, dest, options) {
34
- if( dest === undefined || typeof dest === 'object' ) {
35
- options = dest;
36
- dest = globSrc;
37
- globSrc = '**';
38
- }
39
-
40
- options = _.extend({}, options || {}, dirpath ? { cwd: dirpath } : {} );
41
-
42
- dirExpand(globSrc, _.extend({}, options.cwd ? { cwd: options.cwd } : {} ) ).forEach(function (filepath) {
43
- var srcPath = joinPaths.root( options.cwd || '.', filepath ),
44
- destPath = joinPaths.root(dest || '.', filepath);
45
-
46
- if( dir.exists( srcPath ).isDirectory() ) {
47
- mkdirp.sync( destPath );
48
- } else {
49
- file.copy( srcPath, destPath );
50
- }
51
- });
52
- return dir;
53
- },
54
- expand: dirExpand,
55
- load: function (dirpath, pattern, options) {
56
- return new Files( dirExpand(pattern, _.extend(options || {}, { cwd: joinPaths.root(dirpath) }) ), { cwd: dirpath });
57
- },
58
- libs2html: function (dirpath, filter, options) {
59
- if( !options ) {
60
- if( !filter ) {
61
- filter = dirpath;
62
- dirpath = '.';
63
- } else if( typeof filter === 'object' && !( filter instanceof Array ) ) {
64
- options = filter;
65
- filter = dirpath;
66
- dirpath = '.';
67
- }
68
- }
69
- options = options || {};
70
-
71
- var files = dirExpand(filter, dirpath),
72
- rootSlash = options.rootSlash === undefined || options.rootSlash,
73
- scriptTail = ( options.version ? ( '?v=' + options.version ) : '' ) + '\"' + ( options.defer ? ' defer' : '' ) + ( options.async ? ' async' : '' ) + '></script>',
74
- styleTail = ( options.version ? ( '?v=' + options.version ) : '' ) + '\" />';
75
-
76
- return files.reduce(function (prev, filepath) {
77
- if( rootSlash ) filepath = '/' + filepath;
78
-
79
- if( /\.js$/.test(filepath) ) {
80
- return prev + '\n <script src="' + filepath + scriptTail;
81
- } else if( /\.css$/.test(filepath) ) {
82
- return prev + '\n <link type="text/css" rel="stylesheet" href="' + filepath + styleTail;
83
- }
84
- return prev;
85
- }, '') + '\n';
86
- },
87
- remove: function (dirpath) {
88
- dirpath = joinPaths.root(dirpath);
89
- if( dir.exists(dirpath) ) exec('rm -r ' + dirpath);
90
- return dir;
91
- }
92
- });
93
-
94
- _.extend(Dir.prototype, {
95
- create: function () {
96
- dir.create(this.dirpath);
97
- return this;
98
- },
99
- exists: function () {
100
- return dir.exists(this.dirpath);
101
- },
102
- expand: function (patterns, options) {
103
- return dir.expand(patterns, _.extend({}, options || {}, { cwd: this.dirpath }) );
104
- },
105
- remove: function () {
106
- dir.remove(this.dirpath);
107
- return this;
108
- },
109
- copy: function (globSrc, dest, options) {
110
- dir.copy( this.dirpath, globSrc, dest, options );
111
- return this;
112
- },
113
- symlink: function (_path, target, type) {
114
- fs.symlinkSync( target, joinPaths.root(this.dirpath, _path), type);
115
- return this;
116
- },
117
- load: function (pattern, options) {
118
- return dir.load(this.dirpath, pattern, options);
119
- },
120
- libs2html: function (filter, options) {
121
- return dir.libs2html(this.dirpath, filter, options);
122
- },
123
- watch: function (handler) {
124
- return require('./nitro').watch(this.dirpath, handler);
125
- }
126
- });
127
-
128
-
129
-
130
- module.exports = dir;