@4399ywkf/core 4.0.61
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/README.md +3 -0
- package/compiled/dotenv/LICENSE +23 -0
- package/compiled/dotenv/index.js +1 -0
- package/compiled/dotenv/lib/main.d.ts +73 -0
- package/compiled/dotenv/package.json +1 -0
- package/compiled/dotenv/types/index.d.ts +59 -0
- package/compiled/dotenv-expand/LICENSE +24 -0
- package/compiled/dotenv-expand/index.js +1 -0
- package/compiled/dotenv-expand/lib/main.d.ts +29 -0
- package/compiled/dotenv-expand/package.json +1 -0
- package/compiled/just-diff/LICENSE +21 -0
- package/compiled/just-diff/index.d.ts +20 -0
- package/compiled/just-diff/index.js +1 -0
- package/compiled/just-diff/package.json +1 -0
- package/dist/config/config.d.ts +62 -0
- package/dist/config/config.js +240 -0
- package/dist/config/utils.d.ts +8 -0
- package/dist/config/utils.js +40 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.js +45 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +51 -0
- package/dist/route/defineRoutes.d.ts +1 -0
- package/dist/route/defineRoutes.js +61 -0
- package/dist/route/route.d.ts +3 -0
- package/dist/route/route.js +27 -0
- package/dist/route/routeUtils.d.ts +8 -0
- package/dist/route/routeUtils.js +46 -0
- package/dist/route/routesConfig.d.ts +6 -0
- package/dist/route/routesConfig.js +125 -0
- package/dist/route/routesConvention.d.ts +5 -0
- package/dist/route/routesConvention.js +88 -0
- package/dist/route/utils.d.ts +8 -0
- package/dist/route/utils.js +59 -0
- package/dist/service/command.d.ts +30 -0
- package/dist/service/command.js +46 -0
- package/dist/service/env.d.ts +4 -0
- package/dist/service/env.js +46 -0
- package/dist/service/generatePlugin.d.ts +4 -0
- package/dist/service/generatePlugin.js +102 -0
- package/dist/service/generator.d.ts +71 -0
- package/dist/service/generator.js +40 -0
- package/dist/service/hook.d.ts +16 -0
- package/dist/service/hook.js +57 -0
- package/dist/service/path.d.ts +15 -0
- package/dist/service/path.js +55 -0
- package/dist/service/plugin.d.ts +61 -0
- package/dist/service/plugin.js +177 -0
- package/dist/service/pluginAPI.d.ts +49 -0
- package/dist/service/pluginAPI.js +237 -0
- package/dist/service/service.d.ts +147 -0
- package/dist/service/service.js +538 -0
- package/dist/service/servicePlugin.d.ts +3 -0
- package/dist/service/servicePlugin.js +37 -0
- package/dist/service/telemetry.d.ts +32 -0
- package/dist/service/telemetry.js +127 -0
- package/dist/service/utils.d.ts +2 -0
- package/dist/service/utils.js +36 -0
- package/dist/types.d.ts +116 -0
- package/dist/types.js +77 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Copyright (c) 2015, Scott Motte
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
15
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
18
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
19
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
20
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
23
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){var e={875:function(e,r,n){const o=n(147);const t=n(17);const s=n(37);const i=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function parse(e){const r={};let n=e.toString();n=n.replace(/\r\n?/gm,"\n");let o;while((o=i.exec(n))!=null){const e=o[1];let n=o[2]||"";n=n.trim();const t=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,"$2");if(t==='"'){n=n.replace(/\\n/g,"\n");n=n.replace(/\\r/g,"\r")}r[e]=n}return r}function _log(e){console.log(`[dotenv][DEBUG] ${e}`)}function _resolveHome(e){return e[0]==="~"?t.join(s.homedir(),e.slice(1)):e}function config(e){let r=t.resolve(process.cwd(),".env");let n="utf8";const s=Boolean(e&&e.debug);const i=Boolean(e&&e.override);if(e){if(e.path!=null){r=_resolveHome(e.path)}if(e.encoding!=null){n=e.encoding}}try{const e=c.parse(o.readFileSync(r,{encoding:n}));Object.keys(e).forEach((function(r){if(!Object.prototype.hasOwnProperty.call(process.env,r)){process.env[r]=e[r]}else{if(i===true){process.env[r]=e[r]}if(s){if(i===true){_log(`"${r}" is already defined in \`process.env\` and WAS overwritten`)}else{_log(`"${r}" is already defined in \`process.env\` and was NOT overwritten`)}}}}));return{parsed:e}}catch(e){if(s){_log(`Failed to load ${r} ${e.message}`)}return{error:e}}}const c={config:config,parse:parse};e.exports.config=c.config;e.exports.parse=c.parse;e.exports=c},147:function(e){"use strict";e.exports=require("fs")},37:function(e){"use strict";e.exports=require("os")},17:function(e){"use strict";e.exports=require("path")}};var r={};function __nccwpck_require__(n){var o=r[n];if(o!==undefined){return o.exports}var t=r[n]={exports:{}};var s=true;try{e[n](t,t.exports,__nccwpck_require__);s=false}finally{if(s)delete r[n]}return t.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(875);module.exports=n})();
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// TypeScript Version: 3.0
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
|
|
4
|
+
export interface DotenvParseOutput {
|
|
5
|
+
[name: string]: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parses a string or buffer in the .env file format into an object.
|
|
10
|
+
*
|
|
11
|
+
* See https://docs.dotenv.org
|
|
12
|
+
*
|
|
13
|
+
* @param src - contents to be parsed. example: `'DB_HOST=localhost'`
|
|
14
|
+
* @param options - additional options. example: `{ debug: true }`
|
|
15
|
+
* @returns an object with keys and values based on `src`. example: `{ DB_HOST : 'localhost' }`
|
|
16
|
+
*/
|
|
17
|
+
export function parse<T extends DotenvParseOutput = DotenvParseOutput>(
|
|
18
|
+
src: string | Buffer
|
|
19
|
+
): T;
|
|
20
|
+
|
|
21
|
+
export interface DotenvConfigOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Default: `path.resolve(process.cwd(), '.env')`
|
|
24
|
+
*
|
|
25
|
+
* Specify a custom path if your file containing environment variables is located elsewhere.
|
|
26
|
+
*
|
|
27
|
+
* example: `require('dotenv').config({ path: '/custom/path/to/.env' })`
|
|
28
|
+
*/
|
|
29
|
+
path?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Default: `utf8`
|
|
33
|
+
*
|
|
34
|
+
* Specify the encoding of your file containing environment variables.
|
|
35
|
+
*
|
|
36
|
+
* example: `require('dotenv').config({ encoding: 'latin1' })`
|
|
37
|
+
*/
|
|
38
|
+
encoding?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Default: `false`
|
|
42
|
+
*
|
|
43
|
+
* Turn on logging to help debug why certain keys or values are not being set as you expect.
|
|
44
|
+
*
|
|
45
|
+
* example: `require('dotenv').config({ debug: process.env.DEBUG })`
|
|
46
|
+
*/
|
|
47
|
+
debug?: boolean;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Default: `false`
|
|
51
|
+
*
|
|
52
|
+
* Override any environment variables that have already been set on your machine with values from your .env file.
|
|
53
|
+
*
|
|
54
|
+
* example: `require('dotenv').config({ override: true })`
|
|
55
|
+
*/
|
|
56
|
+
override?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface DotenvConfigOutput {
|
|
60
|
+
error?: Error;
|
|
61
|
+
parsed?: DotenvParseOutput;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Loads `.env` file contents into process.env.
|
|
66
|
+
*
|
|
67
|
+
* See https://docs.dotenv.org
|
|
68
|
+
*
|
|
69
|
+
* @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', debug: true, override: false }`
|
|
70
|
+
* @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"dotenv","license":"BSD-2-Clause","types":"lib/main.d.ts"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// TypeScript Version: 3.0
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
|
|
4
|
+
export interface DotenvParseOptions {
|
|
5
|
+
/**
|
|
6
|
+
* You may turn on logging to help debug why certain keys or values are not being set as you expect.
|
|
7
|
+
*/
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface DotenvParseOutput {
|
|
12
|
+
[name: string]: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Parses a string or buffer in the .env file format into an object.
|
|
17
|
+
*
|
|
18
|
+
* @param src - contents to be parsed
|
|
19
|
+
* @param options - additional options
|
|
20
|
+
* @returns an object with keys and values based on `src`
|
|
21
|
+
*/
|
|
22
|
+
export function parse<T extends DotenvParseOutput = DotenvParseOutput>(
|
|
23
|
+
src: string | Buffer,
|
|
24
|
+
options?: DotenvParseOptions
|
|
25
|
+
): T;
|
|
26
|
+
|
|
27
|
+
export interface DotenvConfigOptions {
|
|
28
|
+
/**
|
|
29
|
+
* You may specify a custom path if your file containing environment variables is located elsewhere.
|
|
30
|
+
*/
|
|
31
|
+
path?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* You may specify the encoding of your file containing environment variables.
|
|
35
|
+
*/
|
|
36
|
+
encoding?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* You may turn on logging to help debug why certain keys or values are not being set as you expect.
|
|
40
|
+
*/
|
|
41
|
+
debug?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface DotenvConfigOutput {
|
|
45
|
+
error?: Error;
|
|
46
|
+
parsed?: DotenvParseOutput;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Loads `.env` file contents into {@link https://nodejs.org/api/process.html#process_process_env `process.env`}.
|
|
51
|
+
* Example: 'KEY=value' becomes { parsed: { KEY: 'value' } }
|
|
52
|
+
*
|
|
53
|
+
* @param options - controls behavior
|
|
54
|
+
* @returns an object with a `parsed` key if successful or `error` key if an error occurred
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
|
|
58
|
+
/** @deprecated since v7.0.0 Use config instead. */
|
|
59
|
+
export const load: typeof config;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Copyright (c) 2016, Scott Motte
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
15
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
18
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
19
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
20
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
23
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
24
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";var e={212:function(e){function _interpolate(e,r,t){const n=e.match(/(.?\${*[\w]*(?::-[\w/]*)?}*)/g)||[];return n.reduce((function(e,o,a){const p=/(.?)\${*([\w]*(?::-[\w/]*)?)?}*/g.exec(o);if(!p||p.length===0){return e}const s=p[1];let c,i;if(s==="\\"){i=p[0];c=i.replace("\\$","$")}else{const o=p[2].split(":-");const _=o[0];i=p[0].substring(s.length);c=Object.prototype.hasOwnProperty.call(r,_)?r[_]:t.parsed[_]||o[1]||"";if(o.length>1&&c){const r=n[a+1];n[a+1]="";e=e.replace(r,"")}c=_interpolate(c,r,t)}return e.replace(i,c)}),e)}function expand(e){const r=e.ignoreProcessEnv?{}:process.env;for(const t in e.parsed){const n=Object.prototype.hasOwnProperty.call(r,t)?r[t]:e.parsed[t];e.parsed[t]=_interpolate(n,r,e)}for(const t in e.parsed){r[t]=e.parsed[t]}return e}e.exports.expand=expand}};var r={};function __nccwpck_require__(t){var n=r[t];if(n!==undefined){return n.exports}var o=r[t]={exports:{}};var a=true;try{e[t](o,o.exports,__nccwpck_require__);a=false}finally{if(a)delete r[t]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(212);module.exports=t})();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// TypeScript Version: 3.0
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
|
|
4
|
+
export interface DotenvExpandOptions {
|
|
5
|
+
ignoreProcessEnv?: boolean;
|
|
6
|
+
error?: Error;
|
|
7
|
+
parsed?: {
|
|
8
|
+
[name: string]: string;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DotenvExpandOutput {
|
|
13
|
+
ignoreProcessEnv?: boolean;
|
|
14
|
+
error?: Error;
|
|
15
|
+
parsed?: {
|
|
16
|
+
[name: string]: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Adds variable expansion on top of dotenv.
|
|
22
|
+
*
|
|
23
|
+
* See https://docs.dotenv.org
|
|
24
|
+
*
|
|
25
|
+
* @param options - additional options. example: `{ ignoreProcessEnv: false, error: null, parsed: { { KEY: 'value' } }`
|
|
26
|
+
* @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export function expand(options?: DotenvExpandOptions): DotenvExpandOutput
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"dotenv-expand","author":"motdotla","license":"BSD-2-Clause","types":"lib/main.d.ts"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 angus croll
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Definitions by: Cameron Hunter <https://github.com/cameronhunter>
|
|
2
|
+
// Modified by: Angus Croll <https://github.com/angus-c>
|
|
3
|
+
type Operation = "add" | "replace" | "remove";
|
|
4
|
+
|
|
5
|
+
type JSONPatchPathConverter<OUTPUT> = (
|
|
6
|
+
arrayPath: Array<string | number>
|
|
7
|
+
) => OUTPUT;
|
|
8
|
+
|
|
9
|
+
export function diff(
|
|
10
|
+
a: object | Array<any>,
|
|
11
|
+
b: object | Array<any>,
|
|
12
|
+
): Array<{ op: Operation; path: Array<string | number>; value: any }>;
|
|
13
|
+
|
|
14
|
+
export function diff<PATH>(
|
|
15
|
+
a: object | Array<any>,
|
|
16
|
+
b: object | Array<any>,
|
|
17
|
+
jsonPatchPathConverter: JSONPatchPathConverter<PATH>
|
|
18
|
+
): Array<{ op: Operation; path: PATH; value: any }>;
|
|
19
|
+
|
|
20
|
+
export const jsonPatchPathConverter: JSONPatchPathConverter<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){var e={696:function(e){e.exports={diff:diff,jsonPatchPathConverter:jsonPatchPathConverter};function diff(e,r,t){if(!e||typeof e!="object"||!r||typeof r!="object"){throw new Error("both arguments must be objects or arrays")}t||(t=function(e){return e});function getDiff(e,r,a,n){var o=Object.keys(e);var c=o.length;var i=Object.keys(r);var f=i.length;var u;for(var p=0;p<c;p++){var s=Array.isArray(e)?Number(o[p]):o[p];if(!(s in r)){u=a.concat(s);n.remove.push({op:"remove",path:t(u)})}}for(var p=0;p<f;p++){var s=Array.isArray(r)?Number(i[p]):i[p];var v=e[s];var _=r[s];if(!(s in e)){u=a.concat(s);var h=r[s];n.add.push({op:"add",path:t(u),value:h})}else if(v!==_){if(Object(v)!==v||Object(_)!==_){u=pushReplace(u,a,s,n,t,r)}else{if(!Object.keys(v).length&&!Object.keys(_).length&&String(v)!=String(_)){u=pushReplace(u,a,s,n,t,r)}else{getDiff(e[s],r[s],a.concat(s),n)}}}}return n}const a=getDiff(e,r,[],{remove:[],replace:[],add:[]});return a.remove.reverse().concat(a.replace).concat(a.add)}function pushReplace(e,r,t,a,n,o){e=r.concat(t);a.replace.push({op:"replace",path:n(e),value:o[t]});return e}function jsonPatchPathConverter(e){return[""].concat(e).join("/")}}};var r={};function __nccwpck_require__(t){var a=r[t];if(a!==undefined){return a.exports}var n=r[t]={exports:{}};var o=true;try{e[t](n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete r[t]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(696);module.exports=t})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"just-diff","version":"5.2.0","author":"Angus Croll","license":"MIT","types":"index.d.ts"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Env, type IOnChangeTypes } from '../types';
|
|
2
|
+
interface IOpts {
|
|
3
|
+
cwd: string;
|
|
4
|
+
env: Env;
|
|
5
|
+
specifiedEnv?: string;
|
|
6
|
+
defaultConfigFiles?: string[];
|
|
7
|
+
}
|
|
8
|
+
declare type ISchema = Record<string, any>;
|
|
9
|
+
export declare class Config {
|
|
10
|
+
opts: IOpts;
|
|
11
|
+
mainConfigFile: string | null;
|
|
12
|
+
prevConfig: any;
|
|
13
|
+
files: string[];
|
|
14
|
+
constructor(opts: IOpts);
|
|
15
|
+
getUserConfig(): {
|
|
16
|
+
config: {};
|
|
17
|
+
files: string[];
|
|
18
|
+
};
|
|
19
|
+
getConfig(opts: {
|
|
20
|
+
schemas: ISchema;
|
|
21
|
+
}): {
|
|
22
|
+
config: {};
|
|
23
|
+
files: string[];
|
|
24
|
+
};
|
|
25
|
+
watch(opts: {
|
|
26
|
+
schemas: ISchema;
|
|
27
|
+
onChangeTypes: IOnChangeTypes;
|
|
28
|
+
onChange: (opts: {
|
|
29
|
+
data: ReturnType<typeof Config.diffConfigs>;
|
|
30
|
+
event: string;
|
|
31
|
+
path: string;
|
|
32
|
+
}) => Promise<void>;
|
|
33
|
+
}): () => Promise<void>;
|
|
34
|
+
static getMainConfigFile(opts: {
|
|
35
|
+
cwd: string;
|
|
36
|
+
defaultConfigFiles?: string[];
|
|
37
|
+
}): string | null;
|
|
38
|
+
static getConfigFiles(opts: {
|
|
39
|
+
mainConfigFile: string | null;
|
|
40
|
+
env: Env;
|
|
41
|
+
specifiedEnv?: string;
|
|
42
|
+
}): string[];
|
|
43
|
+
static getUserConfig(opts: {
|
|
44
|
+
configFiles: string[];
|
|
45
|
+
}): {
|
|
46
|
+
config: {};
|
|
47
|
+
files: string[];
|
|
48
|
+
};
|
|
49
|
+
static validateConfig(opts: {
|
|
50
|
+
config: any;
|
|
51
|
+
schemas: ISchema;
|
|
52
|
+
}): void;
|
|
53
|
+
static diffConfigs(opts: {
|
|
54
|
+
origin: any;
|
|
55
|
+
updated: any;
|
|
56
|
+
onChangeTypes: IOnChangeTypes;
|
|
57
|
+
}): {
|
|
58
|
+
changes: Record<string, string[]>;
|
|
59
|
+
fns: Function[];
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/config/config.ts
|
|
30
|
+
var config_exports = {};
|
|
31
|
+
__export(config_exports, {
|
|
32
|
+
Config: () => Config
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(config_exports);
|
|
35
|
+
var import_esbuild = __toESM(require("@4399ywkf/bundler-utils/compiled/esbuild"));
|
|
36
|
+
var import_utils = require("@4399ywkf/utils");
|
|
37
|
+
var import_joi = __toESM(require("@4399ywkf/utils/compiled/@hapi/joi"));
|
|
38
|
+
var import_assert = __toESM(require("assert"));
|
|
39
|
+
var import_fs = require("fs");
|
|
40
|
+
var import_path = require("path");
|
|
41
|
+
var import_just_diff = require("../../compiled/just-diff");
|
|
42
|
+
var import_constants = require("../constants");
|
|
43
|
+
var import_types = require("../types");
|
|
44
|
+
var import_utils2 = require("./utils");
|
|
45
|
+
var Config = class _Config {
|
|
46
|
+
opts;
|
|
47
|
+
mainConfigFile;
|
|
48
|
+
prevConfig;
|
|
49
|
+
files = [];
|
|
50
|
+
constructor(opts) {
|
|
51
|
+
this.opts = opts;
|
|
52
|
+
this.mainConfigFile = _Config.getMainConfigFile(this.opts);
|
|
53
|
+
this.prevConfig = null;
|
|
54
|
+
}
|
|
55
|
+
getUserConfig() {
|
|
56
|
+
const configFiles = _Config.getConfigFiles({
|
|
57
|
+
mainConfigFile: this.mainConfigFile,
|
|
58
|
+
env: this.opts.env,
|
|
59
|
+
specifiedEnv: this.opts.specifiedEnv
|
|
60
|
+
});
|
|
61
|
+
return _Config.getUserConfig({
|
|
62
|
+
configFiles: (0, import_utils2.getAbsFiles)({
|
|
63
|
+
files: configFiles,
|
|
64
|
+
cwd: this.opts.cwd
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
getConfig(opts) {
|
|
69
|
+
const { config, files } = this.getUserConfig();
|
|
70
|
+
_Config.validateConfig({ config, schemas: opts.schemas });
|
|
71
|
+
this.files = files;
|
|
72
|
+
return this.prevConfig = {
|
|
73
|
+
config,
|
|
74
|
+
files
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
watch(opts) {
|
|
78
|
+
const watcher = import_utils.chokidar.watch(
|
|
79
|
+
[
|
|
80
|
+
...this.files,
|
|
81
|
+
...this.mainConfigFile ? [] : (0, import_utils2.getAbsFiles)({
|
|
82
|
+
files: this.opts.defaultConfigFiles || import_constants.DEFAULT_CONFIG_FILES,
|
|
83
|
+
cwd: this.opts.cwd
|
|
84
|
+
})
|
|
85
|
+
],
|
|
86
|
+
{
|
|
87
|
+
ignoreInitial: true,
|
|
88
|
+
cwd: this.opts.cwd
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
watcher.on(
|
|
92
|
+
"all",
|
|
93
|
+
import_utils.lodash.debounce((event, path) => {
|
|
94
|
+
const { config: origin } = this.prevConfig;
|
|
95
|
+
const { config: updated, files } = this.getConfig({
|
|
96
|
+
schemas: opts.schemas
|
|
97
|
+
});
|
|
98
|
+
watcher.add(files);
|
|
99
|
+
const data = _Config.diffConfigs({
|
|
100
|
+
origin,
|
|
101
|
+
updated,
|
|
102
|
+
onChangeTypes: opts.onChangeTypes
|
|
103
|
+
});
|
|
104
|
+
opts.onChange({
|
|
105
|
+
data,
|
|
106
|
+
event,
|
|
107
|
+
path
|
|
108
|
+
}).catch((e) => {
|
|
109
|
+
throw e;
|
|
110
|
+
});
|
|
111
|
+
}, import_constants.WATCH_DEBOUNCE_STEP)
|
|
112
|
+
);
|
|
113
|
+
return () => watcher.close();
|
|
114
|
+
}
|
|
115
|
+
static getMainConfigFile(opts) {
|
|
116
|
+
let mainConfigFile = null;
|
|
117
|
+
for (const configFile of opts.defaultConfigFiles || import_constants.DEFAULT_CONFIG_FILES) {
|
|
118
|
+
const absConfigFile = (0, import_path.join)(opts.cwd, configFile);
|
|
119
|
+
if ((0, import_fs.existsSync)(absConfigFile)) {
|
|
120
|
+
mainConfigFile = absConfigFile;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return mainConfigFile;
|
|
125
|
+
}
|
|
126
|
+
static getConfigFiles(opts) {
|
|
127
|
+
const ret = [];
|
|
128
|
+
const { mainConfigFile } = opts;
|
|
129
|
+
const specifiedEnv = opts.specifiedEnv || "";
|
|
130
|
+
if (mainConfigFile) {
|
|
131
|
+
const env = import_constants.SHORT_ENV[opts.env] || opts.env;
|
|
132
|
+
ret.push(
|
|
133
|
+
...[
|
|
134
|
+
mainConfigFile,
|
|
135
|
+
specifiedEnv && (0, import_utils2.addExt)({ file: mainConfigFile, ext: `.${specifiedEnv}` }),
|
|
136
|
+
(0, import_utils2.addExt)({ file: mainConfigFile, ext: `.${env}` }),
|
|
137
|
+
specifiedEnv && (0, import_utils2.addExt)({
|
|
138
|
+
file: mainConfigFile,
|
|
139
|
+
ext: `.${env}.${specifiedEnv}`
|
|
140
|
+
})
|
|
141
|
+
].filter(Boolean)
|
|
142
|
+
);
|
|
143
|
+
if (opts.env === import_types.Env.development) {
|
|
144
|
+
ret.push((0, import_utils2.addExt)({ file: mainConfigFile, ext: import_constants.LOCAL_EXT }));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return ret;
|
|
148
|
+
}
|
|
149
|
+
static getUserConfig(opts) {
|
|
150
|
+
let config = {};
|
|
151
|
+
let files = [];
|
|
152
|
+
for (const configFile of opts.configFiles) {
|
|
153
|
+
if ((0, import_fs.existsSync)(configFile)) {
|
|
154
|
+
import_utils.register.register({
|
|
155
|
+
implementor: import_esbuild.default
|
|
156
|
+
});
|
|
157
|
+
import_utils.register.clearFiles();
|
|
158
|
+
try {
|
|
159
|
+
config = import_utils.lodash.merge(config, require(configFile).default);
|
|
160
|
+
} catch (e) {
|
|
161
|
+
if (import_utils.semver.lt(import_utils.semver.clean(process.version), "16.9.0")) {
|
|
162
|
+
throw e;
|
|
163
|
+
}
|
|
164
|
+
throw new Error(`Parse config file failed: [${configFile}]`, {
|
|
165
|
+
cause: e
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
for (const file of import_utils.register.getFiles()) {
|
|
169
|
+
delete require.cache[file];
|
|
170
|
+
}
|
|
171
|
+
files.push(...import_utils.register.getFiles());
|
|
172
|
+
import_utils.register.restore();
|
|
173
|
+
} else {
|
|
174
|
+
files.push(configFile);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
config,
|
|
179
|
+
files
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
static validateConfig(opts) {
|
|
183
|
+
const errors = /* @__PURE__ */ new Map();
|
|
184
|
+
const configKeys = new Set(Object.keys(opts.config));
|
|
185
|
+
for (const key of Object.keys(opts.schemas)) {
|
|
186
|
+
configKeys.delete(key);
|
|
187
|
+
if (!opts.config[key]) continue;
|
|
188
|
+
const schema = opts.schemas[key]({ ...import_joi.default, zod: import_utils.zod });
|
|
189
|
+
if (import_joi.default.isSchema(schema)) {
|
|
190
|
+
const { error } = schema.validate(opts.config[key]);
|
|
191
|
+
if (error) errors.set(key, error);
|
|
192
|
+
} else {
|
|
193
|
+
(0, import_assert.default)(
|
|
194
|
+
(0, import_utils.isZodSchema)(schema),
|
|
195
|
+
`schema for config ${key} is not valid, neither joi nor zod.`
|
|
196
|
+
);
|
|
197
|
+
const { error } = schema.safeParse(opts.config[key]);
|
|
198
|
+
if (error) errors.set(key, error);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
(0, import_assert.default)(
|
|
202
|
+
errors.size === 0,
|
|
203
|
+
`Invalid config values: ${Array.from(errors.keys()).join(", ")}
|
|
204
|
+
${Array.from(errors.keys()).map((key) => {
|
|
205
|
+
return `Invalid value for ${key}:
|
|
206
|
+
${errors.get(key).message}`;
|
|
207
|
+
})}`
|
|
208
|
+
);
|
|
209
|
+
(0, import_assert.default)(
|
|
210
|
+
configKeys.size === 0,
|
|
211
|
+
`Invalid config keys: ${Array.from(configKeys).join(", ")}`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
static diffConfigs(opts) {
|
|
215
|
+
const patch = (0, import_just_diff.diff)(opts.origin, opts.updated);
|
|
216
|
+
const changes = {};
|
|
217
|
+
const fns = [];
|
|
218
|
+
for (const item of patch) {
|
|
219
|
+
const key = item.path[0];
|
|
220
|
+
const onChange = opts.onChangeTypes[key];
|
|
221
|
+
(0, import_assert.default)(onChange, `Invalid onChange config for key ${key}`);
|
|
222
|
+
if (typeof onChange === "string") {
|
|
223
|
+
changes[onChange] || (changes[onChange] = []);
|
|
224
|
+
changes[onChange].push(String(key));
|
|
225
|
+
} else if (typeof onChange === "function") {
|
|
226
|
+
fns.push(onChange);
|
|
227
|
+
} else {
|
|
228
|
+
throw new Error(`Invalid onChange value for key ${key}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
changes,
|
|
233
|
+
fns
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
238
|
+
0 && (module.exports = {
|
|
239
|
+
Config
|
|
240
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/config/utils.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
addExt: () => addExt,
|
|
23
|
+
getAbsFiles: () => getAbsFiles
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
function addExt(opts) {
|
|
28
|
+
const index = opts.file.lastIndexOf(".");
|
|
29
|
+
return `${opts.file.slice(0, index)}${opts.ext}${opts.file.slice(index)}`;
|
|
30
|
+
}
|
|
31
|
+
function getAbsFiles(opts) {
|
|
32
|
+
return opts.files.map((file) => {
|
|
33
|
+
return (0, import_path.isAbsolute)(file) ? file : (0, import_path.join)(opts.cwd, file);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
addExt,
|
|
39
|
+
getAbsFiles
|
|
40
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const DEFAULT_CONFIG_FILES: string[];
|
|
2
|
+
export declare const SHORT_ENV: {
|
|
3
|
+
development: string;
|
|
4
|
+
production: string;
|
|
5
|
+
test: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const LOCAL_EXT = ".local";
|
|
8
|
+
export declare const WATCH_DEBOUNCE_STEP = 300;
|
|
9
|
+
export declare const DEFAULT_FRAMEWORK_NAME = "umi";
|