auth0-deploy-cli 7.4.0 → 7.5.2

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 (112) hide show
  1. package/.circleci/config.yml +15 -0
  2. package/.eslintrc +66 -17
  3. package/.github/CODEOWNERS +1 -0
  4. package/.husky/pre-commit +2 -0
  5. package/CHANGELOG.md +27 -2
  6. package/lib/args.js +94 -81
  7. package/lib/commands/export.js +54 -78
  8. package/lib/commands/import.js +46 -70
  9. package/lib/commands/index.js +11 -20
  10. package/lib/configFactory.js +19 -27
  11. package/lib/context/defaults.js +18 -41
  12. package/lib/context/directory/handlers/actions.js +77 -107
  13. package/lib/context/directory/handlers/attackProtection.js +59 -0
  14. package/lib/context/directory/handlers/clientGrants.js +45 -54
  15. package/lib/context/directory/handlers/clients.js +60 -79
  16. package/lib/context/directory/handlers/connections.js +65 -89
  17. package/lib/context/directory/handlers/databases.js +91 -123
  18. package/lib/context/directory/handlers/emailProvider.js +46 -57
  19. package/lib/context/directory/handlers/emailTemplates.js +67 -80
  20. package/lib/context/directory/handlers/guardianFactorProviders.js +41 -49
  21. package/lib/context/directory/handlers/guardianFactorTemplates.js +41 -49
  22. package/lib/context/directory/handlers/guardianFactors.js +41 -49
  23. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +40 -50
  24. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +40 -50
  25. package/lib/context/directory/handlers/guardianPolicies.js +40 -50
  26. package/lib/context/directory/handlers/hooks.js +55 -70
  27. package/lib/context/directory/handlers/index.js +53 -123
  28. package/lib/context/directory/handlers/migrations.js +36 -41
  29. package/lib/context/directory/handlers/organizations.js +54 -69
  30. package/lib/context/directory/handlers/pages.js +72 -86
  31. package/lib/context/directory/handlers/resourceServers.js +41 -49
  32. package/lib/context/directory/handlers/roles.js +49 -62
  33. package/lib/context/directory/handlers/rules.js +52 -68
  34. package/lib/context/directory/handlers/rulesConfigs.js +33 -32
  35. package/lib/context/directory/handlers/tenant.js +52 -47
  36. package/lib/context/directory/handlers/triggers.js +39 -54
  37. package/lib/context/directory/index.js +113 -101
  38. package/lib/context/index.js +96 -105
  39. package/lib/context/yaml/handlers/actions.js +71 -88
  40. package/lib/context/yaml/handlers/attackProtection.js +29 -0
  41. package/lib/context/yaml/handlers/clientGrants.js +36 -29
  42. package/lib/context/yaml/handlers/clients.js +61 -76
  43. package/lib/context/yaml/handlers/connections.js +76 -103
  44. package/lib/context/yaml/handlers/databases.js +64 -79
  45. package/lib/context/yaml/handlers/emailProvider.js +33 -30
  46. package/lib/context/yaml/handlers/emailTemplates.js +45 -54
  47. package/lib/context/yaml/handlers/guardianFactorProviders.js +27 -18
  48. package/lib/context/yaml/handlers/guardianFactorTemplates.js +27 -18
  49. package/lib/context/yaml/handlers/guardianFactors.js +27 -18
  50. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +27 -20
  51. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +27 -20
  52. package/lib/context/yaml/handlers/guardianPolicies.js +27 -20
  53. package/lib/context/yaml/handlers/hooks.js +57 -67
  54. package/lib/context/yaml/handlers/index.js +53 -123
  55. package/lib/context/yaml/handlers/migrations.js +23 -24
  56. package/lib/context/yaml/handlers/organizations.js +40 -38
  57. package/lib/context/yaml/handlers/pages.js +49 -58
  58. package/lib/context/yaml/handlers/resourceServers.js +27 -18
  59. package/lib/context/yaml/handlers/roles.js +34 -24
  60. package/lib/context/yaml/handlers/rules.js +48 -58
  61. package/lib/context/yaml/handlers/rulesConfigs.js +27 -18
  62. package/lib/context/yaml/handlers/tenant.js +44 -30
  63. package/lib/context/yaml/handlers/triggers.js +32 -23
  64. package/lib/context/yaml/index.js +127 -142
  65. package/lib/index.js +73 -79
  66. package/lib/logger.js +18 -22
  67. package/lib/readonly.js +74 -66
  68. package/lib/tools/ValidationError.js +8 -13
  69. package/lib/tools/auth0/client.js +143 -133
  70. package/lib/tools/auth0/handlers/actions.js +231 -243
  71. package/lib/tools/auth0/handlers/attackProtection.js +86 -0
  72. package/lib/tools/auth0/handlers/branding.js +47 -46
  73. package/lib/tools/auth0/handlers/clientGrants.js +118 -116
  74. package/lib/tools/auth0/handlers/clients.js +72 -90
  75. package/lib/tools/auth0/handlers/connections.js +150 -118
  76. package/lib/tools/auth0/handlers/databases.js +127 -124
  77. package/lib/tools/auth0/handlers/default.js +186 -189
  78. package/lib/tools/auth0/handlers/emailProvider.js +67 -78
  79. package/lib/tools/auth0/handlers/emailTemplates.js +116 -92
  80. package/lib/tools/auth0/handlers/guardianFactorProviders.js +66 -81
  81. package/lib/tools/auth0/handlers/guardianFactorTemplates.js +60 -71
  82. package/lib/tools/auth0/handlers/guardianFactors.js +56 -63
  83. package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +80 -79
  84. package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +77 -76
  85. package/lib/tools/auth0/handlers/guardianPolicies.js +59 -62
  86. package/lib/tools/auth0/handlers/hooks.js +201 -227
  87. package/lib/tools/auth0/handlers/index.js +53 -111
  88. package/lib/tools/auth0/handlers/migrations.js +99 -79
  89. package/lib/tools/auth0/handlers/organizations.js +225 -247
  90. package/lib/tools/auth0/handlers/pages.js +116 -154
  91. package/lib/tools/auth0/handlers/prompts.js +47 -46
  92. package/lib/tools/auth0/handlers/resourceServers.js +88 -112
  93. package/lib/tools/auth0/handlers/roles.js +203 -220
  94. package/lib/tools/auth0/handlers/rules.js +168 -189
  95. package/lib/tools/auth0/handlers/rulesConfigs.js +54 -63
  96. package/lib/tools/auth0/handlers/tenant.js +88 -64
  97. package/lib/tools/auth0/handlers/triggers.js +126 -126
  98. package/lib/tools/auth0/index.js +92 -85
  99. package/lib/tools/auth0/schema.js +39 -31
  100. package/lib/tools/constants.js +111 -21
  101. package/lib/tools/deploy.js +35 -32
  102. package/lib/tools/index.js +19 -32
  103. package/lib/tools/logger.js +11 -12
  104. package/lib/tools/utils.js +255 -282
  105. package/lib/utils.js +167 -190
  106. package/package.json +10 -16
  107. package/tsconfig.json +17 -0
  108. package/typescript-migration-progress.sh +22 -0
  109. package/.babelrc +0 -17
  110. package/.nyc_output/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
  111. package/.nyc_output/processinfo/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
  112. package/.nyc_output/processinfo/index.json +0 -1
@@ -47,6 +47,15 @@ jobs:
47
47
  - run:
48
48
  name: Publish package
49
49
  command: npm publish
50
+
51
+ ts_migration_progress:
52
+ machine:
53
+ image: ubuntu-2004:202111-02
54
+ steps:
55
+ - checkout
56
+ - run :
57
+ name: Typescript Migration Progress
58
+ command: sh typescript-migration-progress.sh
50
59
 
51
60
  workflows:
52
61
  version: 2
@@ -77,3 +86,9 @@ workflows:
77
86
  ignore: /.*/
78
87
  tags:
79
88
  only: /^v.*/
89
+ ts_migration:
90
+ jobs:
91
+ - ts_migration_progress:
92
+ filters:
93
+ tags:
94
+ ignore: /.*/
package/.eslintrc CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "parser": "@babel/eslint-parser",
2
+ "parser": "@typescript-eslint/parser",
3
3
  "parserOptions": {
4
4
  "ecmaVersion": 2020
5
5
  },
@@ -15,20 +15,40 @@
15
15
  },
16
16
  "settings": {
17
17
  "import/resolver": {
18
- "babel-module": {}
18
+ "node": {
19
+ "extensions": [
20
+ ".js",
21
+ ".ts"
22
+ ]
23
+ }
19
24
  }
20
25
  },
21
26
  "rules": {
22
27
  "max-len": 0,
23
28
  "react/display-name": 0,
24
- "array-bracket-spacing": [2, "always"],
29
+ "array-bracket-spacing": [
30
+ 2,
31
+ "always"
32
+ ],
25
33
  "class-methods-use-this": 0,
26
- "comma-dangle": [2, "never"],
34
+ "comma-dangle": [
35
+ 2,
36
+ "never"
37
+ ],
27
38
  "eol-last": 2,
28
- "indent": [2, 2, {
29
- "SwitchCase": 1
30
- }],
31
- "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
39
+ "indent": [
40
+ 2,
41
+ 2,
42
+ {
43
+ "SwitchCase": 1
44
+ }
45
+ ],
46
+ "import/no-extraneous-dependencies": [
47
+ "error",
48
+ {
49
+ "devDependencies": true
50
+ }
51
+ ],
32
52
  "import/no-dynamic-require": 0,
33
53
  "prefer-arrow-callback": 0,
34
54
  "object-shorthand": 0,
@@ -38,17 +58,46 @@
38
58
  "no-await-in-loop": 0,
39
59
  "no-param-reassign": 0,
40
60
  "no-multiple-empty-lines": 2,
41
- "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
61
+ "no-plusplus": [
62
+ "error",
63
+ {
64
+ "allowForLoopAfterthoughts": true
65
+ }
66
+ ],
42
67
  "no-unused-vars": 2,
43
68
  "no-var": 0,
44
- "object-curly-spacing": [2, "always"],
45
- "quotes": [2, "single", "avoid-escape"],
46
- "semi": [2, "always"],
69
+ "object-curly-spacing": [
70
+ 2,
71
+ "always"
72
+ ],
73
+ "quotes": [
74
+ 2,
75
+ "single",
76
+ "avoid-escape"
77
+ ],
78
+ "semi": [
79
+ 2,
80
+ "always"
81
+ ],
47
82
  "strict": 0,
48
- "space-before-blocks": [2, "always"],
49
- "space-before-function-paren": [2, {
50
- "anonymous": "never",
51
- "named": "never"
52
- }]
83
+ "space-before-blocks": [
84
+ 2,
85
+ "always"
86
+ ],
87
+ "space-before-function-paren": [
88
+ 2,
89
+ {
90
+ "anonymous": "never",
91
+ "named": "never"
92
+ }
93
+ ],
94
+ "import/extensions": [
95
+ "error",
96
+ "ignorePackages",
97
+ {
98
+ "js": "never",
99
+ "ts": "never"
100
+ }
101
+ ]
53
102
  }
54
103
  }
@@ -0,0 +1 @@
1
+ * @auth0/dx-customer-dev-tools-engineer
package/.husky/pre-commit CHANGED
@@ -2,3 +2,5 @@
2
2
  . "$(dirname "$0")/_/husky.sh"
3
3
 
4
4
  npm run lint:fix
5
+
6
+ /bin/bash ./typescript-migration-progress.sh
package/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.5.2] - 2022-03-15
11
+ ### Fixed
12
+ - Resetting this version to be latest on NPM
13
+
14
+ ## [7.5.1] - 2022-03-11
15
+ ### Fixed
16
+ - Updating dead link in logging output [#436]
17
+ - Fixing `--env` flag to properly dictate environment variable inheritance [#432]
18
+
19
+ ## [7.5.0] - 2022-03-08
20
+ ### Added
21
+ - Support for attack protection configuration management [#428]
22
+
23
+ ### Fixed
24
+ - Excluded connection properties from getting deleted upon update [#430]
25
+ - Organizations in YAML format are skipped when not defined [#388]
26
+
10
27
  ## [7.4.0] - 2022-02-24
11
28
  ### Added
12
29
  - Allowing @@ array variable replacement to work when wrapped in quotes [#421]
@@ -426,6 +443,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
426
443
  [#364]: https://github.com/auth0/auth0-deploy-cli/issues/364
427
444
  [#367]: https://github.com/auth0/auth0-deploy-cli/issues/367
428
445
  [#379]: https://github.com/auth0/auth0-deploy-cli/issues/379
446
+ [#388]: https://github.com/auth0/auth0-deploy-cli/issues/388
429
447
  [#400]: https://github.com/auth0/auth0-deploy-cli/issues/400
430
448
  [#401]: https://github.com/auth0/auth0-deploy-cli/issues/401
431
449
  [#403]: https://github.com/auth0/auth0-deploy-cli/issues/403
@@ -434,8 +452,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
434
452
  [#412]: https://github.com/auth0/auth0-deploy-cli/issues/412
435
453
  [#416]: https://github.com/auth0/auth0-deploy-cli/issues/416
436
454
  [#421]: https://github.com/auth0/auth0-deploy-cli/issues/421
437
-
438
- [Unreleased]: https://github.com/auth0/auth0-deploy-cli/compare/v7.4.0...HEAD
455
+ [#428]: https://github.com/auth0/auth0-deploy-cli/issues/428
456
+ [#430]: https://github.com/auth0/auth0-deploy-cli/issues/430
457
+ [#432]: https://github.com/auth0/auth0-deploy-cli/issues/432
458
+ [#436]: https://github.com/auth0/auth0-deploy-cli/issues/436
459
+
460
+ [Unreleased]: https://github.com/auth0/auth0-deploy-cli/compare/v7.5.2...HEAD
461
+ [7.5.2]: https://github.com/auth0/auth0-deploy-cli/compare/v7.5.1...v7.5.2
462
+ [7.5.1]: https://github.com/auth0/auth0-deploy-cli/compare/v7.5.0...v7.5.1
463
+ [7.5.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.4.0...v7.5.0
439
464
  [7.4.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.3.7...v7.4.0
440
465
  [7.3.7]: https://github.com/auth0/auth0-deploy-cli/compare/v7.3.6...v7.3.7
441
466
  [7.3.6]: https://github.com/auth0/auth0-deploy-cli/compare/v7.3.5...v7.3.6
package/lib/args.js CHANGED
@@ -1,86 +1,99 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getParams = undefined;
7
-
8
- var _yargs = require("yargs");
9
-
10
- var _yargs2 = _interopRequireDefault(_yargs);
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getParams = void 0;
7
+ const yargs_1 = __importDefault(require("yargs"));
14
8
  function getParams() {
15
- const args = _yargs2.default.demandCommand(1, 'A command is required').usage('Auth0 Deploy CLI').option('debug', {
16
- alias: 'd',
17
- describe: 'Dump extra debug information.',
18
- type: 'boolean',
19
- default: false
20
- }).option('proxy_url', {
21
- alias: 'p',
22
- describe: 'A url for proxying requests, only set this if you are behind a proxy.',
23
- type: 'string'
24
- }).command(['import', 'deploy'], 'Deploy Configuration', {
25
- input_file: {
26
- alias: 'i',
27
- describe: 'The updates to deploy. Either a JSON file, or directory that contains the correct file layout. See README and online for more info.',
28
- type: 'string',
29
- demandOption: true
30
- },
31
- config_file: {
32
- alias: 'c',
33
- describe: 'The JSON configuration file.',
34
- type: 'string'
35
- },
36
- env: {
37
- alias: 'e',
38
- describe: 'Override the mappings in config with process.env environment variables.',
39
- type: 'string',
40
- boolean: true,
41
- default: true
42
- },
43
- secret: {
44
- alias: 'x',
45
- describe: 'The client secret, this allows you to encrypt the secret in your build configuration instead of storing it in a config file',
46
- type: 'string'
47
- }
48
- }).command(['export', 'dump'], 'Export Auth0 Tenant Configuration', {
49
- output_folder: {
50
- alias: 'o',
51
- describe: 'The output directory.',
52
- type: 'string',
53
- demandOption: true
54
- },
55
- format: {
56
- alias: 'f',
57
- describe: 'The output format.',
58
- type: 'string',
59
- choices: ['yaml', 'directory'],
60
- demandOption: true
61
- },
62
- config_file: {
63
- alias: 'c',
64
- describe: 'The JSON configuration file.',
65
- type: 'string'
66
- },
67
- secret: {
68
- alias: 'x',
69
- describe: 'The client secret, this allows you to encrypt the secret in your build configuration instead of storing it in a config file',
70
- type: 'string'
71
- },
72
- export_ids: {
73
- alias: 'e',
74
- describe: 'Export identifier field for each object type.',
75
- type: 'boolean',
76
- default: false
77
- }
78
- }).example('$0 export -c config.json -f yaml -o path/to/export', 'Dump Auth0 config to folder in YAML format').example('$0 export -c config.json -f directory -o path/to/export', 'Dump Auth0 config to folder in directory format').example('$0 import -c config.json -i tenant.yaml', 'Deploy Auth0 via YAML').example('$0 import -c config.json -i path/to/files', 'Deploy Auth0 via Path').example('$0 dump -c config.json -f yaml -o path/to/export', 'Dump Auth0 config to folder in YAML format').example('$0 dump -c config.json -f directory -o path/to/export', 'Dump Auth0 config to folder in directory format').example('$0 deploy -c config.json -i tenant.yaml', 'Deploy Auth0 via YAML').example('$0 deploy -c config.json -i path/to/files', 'Deploy Auth0 via Path').epilogue('See README (https://github.com/auth0/auth0-deploy-cli) for more in-depth information on configuration and setup.').wrap(null);
79
-
80
- return args.argv;
9
+ const args = yargs_1.default
10
+ .demandCommand(1, 'A command is required')
11
+ .usage('Auth0 Deploy CLI')
12
+ .option('debug', {
13
+ alias: 'd',
14
+ describe: 'Dump extra debug information.',
15
+ type: 'boolean',
16
+ default: false
17
+ })
18
+ .option('proxy_url', {
19
+ alias: 'p',
20
+ describe: 'A url for proxying requests, only set this if you are behind a proxy.',
21
+ type: 'string'
22
+ })
23
+ .command(['import', 'deploy'], 'Deploy Configuration', {
24
+ input_file: {
25
+ alias: 'i',
26
+ describe: 'The updates to deploy. Either a JSON file, or directory that contains the correct file layout. See README and online for more info.',
27
+ type: 'string',
28
+ demandOption: true
29
+ },
30
+ config_file: {
31
+ alias: 'c',
32
+ describe: 'The JSON configuration file.',
33
+ type: 'string'
34
+ },
35
+ env: {
36
+ alias: 'e',
37
+ describe: 'Override the mappings in config with environment variables.',
38
+ boolean: true,
39
+ default: true
40
+ },
41
+ secret: {
42
+ alias: 'x',
43
+ describe: 'The client secret, this allows you to encrypt the secret in your build configuration instead of storing it in a config file',
44
+ type: 'string'
45
+ }
46
+ })
47
+ .command(['export', 'dump'], 'Export Auth0 Tenant Configuration', {
48
+ output_folder: {
49
+ alias: 'o',
50
+ describe: 'The output directory.',
51
+ type: 'string',
52
+ demandOption: true
53
+ },
54
+ format: {
55
+ alias: 'f',
56
+ describe: 'The output format.',
57
+ type: 'string',
58
+ choices: ['yaml', 'directory'],
59
+ demandOption: true
60
+ },
61
+ config_file: {
62
+ alias: 'c',
63
+ describe: 'The JSON configuration file.',
64
+ type: 'string'
65
+ },
66
+ secret: {
67
+ alias: 'x',
68
+ describe: 'The client secret, this allows you to encrypt the secret in your build configuration instead of storing it in a config file',
69
+ type: 'string'
70
+ },
71
+ env: {
72
+ alias: 'e',
73
+ describe: 'Override the mappings in config with environment variables.',
74
+ boolean: true,
75
+ default: false
76
+ },
77
+ export_ids: {
78
+ alias: 'e',
79
+ describe: 'Export identifier field for each object type.',
80
+ type: 'boolean',
81
+ default: false
82
+ }
83
+ })
84
+ .example('$0 export -c config.json -f yaml -o path/to/export', 'Dump Auth0 config to folder in YAML format')
85
+ .example('$0 export -c config.json -f directory -o path/to/export', 'Dump Auth0 config to folder in directory format')
86
+ .example('$0 import -c config.json -i tenant.yaml', 'Deploy Auth0 via YAML')
87
+ .example('$0 import -c config.json -i path/to/files', 'Deploy Auth0 via Path')
88
+ .example('$0 dump -c config.json -f yaml -o path/to/export', 'Dump Auth0 config to folder in YAML format')
89
+ .example('$0 dump -c config.json -f directory -o path/to/export', 'Dump Auth0 config to folder in directory format')
90
+ .example('$0 deploy -c config.json -i tenant.yaml', 'Deploy Auth0 via YAML')
91
+ .example('$0 deploy -c config.json -i path/to/files', 'Deploy Auth0 via Path')
92
+ .epilogue('See README (https://github.com/auth0/auth0-deploy-cli) for more in-depth information on configuration and setup.')
93
+ .wrap(null);
94
+ return args.argv;
81
95
  }
82
-
96
+ exports.getParams = getParams;
83
97
  exports.default = {
84
- getParams
98
+ getParams
85
99
  };
86
- exports.getParams = getParams;
@@ -1,79 +1,55 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = deploy;
7
-
8
- var _path = require("path");
9
-
10
- var _path2 = _interopRequireDefault(_path);
11
-
12
- var _nconf = require("nconf");
13
-
14
- var _nconf2 = _interopRequireDefault(_nconf);
15
-
16
- var _mkdirp = require("mkdirp");
17
-
18
- var _mkdirp2 = _interopRequireDefault(_mkdirp);
19
-
20
- var _logger = require("../logger");
21
-
22
- var _logger2 = _interopRequireDefault(_logger);
23
-
24
- var _utils = require("../utils");
25
-
26
- var _context = require("../context");
27
-
28
- var _context2 = _interopRequireDefault(_context);
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
- async function deploy(params) {
33
- const {
34
- output_folder: outputFolder,
35
- base_path: basePath,
36
- config_file: configFile,
37
- config: configObj,
38
- export_ids: exportIds,
39
- secret
40
- } = params;
41
-
42
- _nconf2.default.env().use('memory');
43
-
44
- if (configFile) {
45
- _nconf2.default.file(configFile);
46
- }
47
-
48
- const overrides = {
49
- AUTH0_INPUT_FILE: outputFolder,
50
- AUTH0_BASE_PATH: basePath,
51
- AUTH0_CONFIG_FILE: configFile,
52
- ...(configObj || {})
53
- };
54
-
55
- if (secret) {
56
- overrides.AUTH0_CLIENT_SECRET = secret;
57
- }
58
-
59
- if (exportIds) {
60
- overrides.AUTH0_EXPORT_IDENTIFIERS = exportIds;
61
- }
62
-
63
- if (!(0, _utils.isDirectory)(outputFolder)) {
64
- _logger2.default.info(`Creating ${outputFolder}`);
65
-
66
- _mkdirp2.default.sync(outputFolder);
67
- }
68
-
69
- if (params.format === 'yaml') {
70
- overrides.AUTH0_INPUT_FILE = _path2.default.join(outputFolder, 'tenant.yaml');
71
- }
72
-
73
- _nconf2.default.overrides(overrides);
74
-
75
- const context = await (0, _context2.default)(_nconf2.default.get());
76
- await context.dump();
77
-
78
- _logger2.default.info('Export Successful');
79
- }
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const path_1 = __importDefault(require("path"));
16
+ const nconf_1 = __importDefault(require("nconf"));
17
+ const mkdirp_1 = __importDefault(require("mkdirp"));
18
+ const logger_1 = __importDefault(require("../logger"));
19
+ const utils_1 = require("../utils");
20
+ const context_1 = __importDefault(require("../context"));
21
+ function exportCMD(params) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const { output_folder: outputFolder, base_path: basePath, config_file: configFile, config: configObj, export_ids: exportIds, secret: clientSecret, env: shouldInheritEnv = false, } = params;
24
+ if (shouldInheritEnv) {
25
+ nconf_1.default.env().use('memory');
26
+ }
27
+ if (configFile) {
28
+ nconf_1.default.file(configFile);
29
+ }
30
+ const overrides = Object.assign({ AUTH0_INPUT_FILE: outputFolder, AUTH0_BASE_PATH: basePath, AUTH0_CONFIG_FILE: configFile }, configObj || {});
31
+ // Prepare configuration by initializing nconf, then passing that as the provider to the config object
32
+ // Allow passed in secret to override the configured one
33
+ if (clientSecret) {
34
+ overrides.AUTH0_CLIENT_SECRET = clientSecret;
35
+ }
36
+ // Allow passed in export_ids to override the configured one
37
+ if (exportIds) {
38
+ overrides.AUTH0_EXPORT_IDENTIFIERS = exportIds;
39
+ }
40
+ // Check output folder
41
+ if (!(0, utils_1.isDirectory)(outputFolder)) {
42
+ logger_1.default.info(`Creating ${outputFolder}`);
43
+ mkdirp_1.default.sync(outputFolder);
44
+ }
45
+ if (params.format === 'yaml') {
46
+ overrides.AUTH0_INPUT_FILE = path_1.default.join(outputFolder, 'tenant.yaml');
47
+ }
48
+ nconf_1.default.overrides(overrides);
49
+ // Setup context and load
50
+ const context = yield (0, context_1.default)(nconf_1.default.get());
51
+ yield context.dump();
52
+ logger_1.default.info('Export Successful');
53
+ });
54
+ }
55
+ exports.default = exportCMD;
@@ -1,71 +1,47 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = deploy;
7
-
8
- var _nconf = require("nconf");
9
-
10
- var _nconf2 = _interopRequireDefault(_nconf);
11
-
12
- var _configFactory = require("../configFactory");
13
-
14
- var _configFactory2 = _interopRequireDefault(_configFactory);
15
-
16
- var _tools = require("../tools");
17
-
18
- var _logger = require("../logger");
19
-
20
- var _logger2 = _interopRequireDefault(_logger);
21
-
22
- var _context = require("../context");
23
-
24
- var _context2 = _interopRequireDefault(_context);
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- async function deploy(params) {
29
- const {
30
- input_file: inputFile,
31
- base_path: basePath,
32
- config_file: configFile,
33
- config: configObj,
34
- env,
35
- secret
36
- } = params;
37
-
38
- _nconf2.default.env().use('memory');
39
-
40
- if (configFile) {
41
- _nconf2.default.file(configFile);
42
- }
43
-
44
- const overrides = {
45
- AUTH0_INPUT_FILE: inputFile,
46
- AUTH0_BASE_PATH: basePath,
47
- AUTH0_CONFIG_FILE: configFile,
48
- AUTH0_KEYWORD_REPLACE_MAPPINGS: {},
49
- ...(configObj || {})
50
- };
51
-
52
- if (secret) {
53
- overrides.AUTH0_CLIENT_SECRET = secret;
54
- }
55
-
56
- if (env) {
57
- const mappings = _nconf2.default.get('AUTH0_KEYWORD_REPLACE_MAPPINGS') || {};
58
-
59
- _nconf2.default.set('AUTH0_KEYWORD_REPLACE_MAPPINGS', Object.assign(mappings, process.env));
60
- }
61
-
62
- _nconf2.default.overrides(overrides);
63
-
64
- const context = await (0, _context2.default)(_nconf2.default.get());
65
- await context.load();
66
- const config = (0, _configFactory2.default)();
67
- config.setProvider(key => _nconf2.default.get(key));
68
- await (0, _tools.deploy)(context.assets, context.mgmtClient, config);
69
-
70
- _logger2.default.info('Import Successful');
71
- }
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const nconf_1 = __importDefault(require("nconf"));
16
+ const configFactory_1 = __importDefault(require("../configFactory"));
17
+ const tools_1 = require("../tools");
18
+ const logger_1 = __importDefault(require("../logger"));
19
+ const context_1 = __importDefault(require("../context"));
20
+ function importCMD(params) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const { input_file: inputFile, base_path: basePath, config_file: configFile, config: configObj, env: shouldInheritEnv = false, secret: clientSecret } = params;
23
+ if (shouldInheritEnv) {
24
+ nconf_1.default.env().use('memory');
25
+ const mappings = nconf_1.default.get('AUTH0_KEYWORD_REPLACE_MAPPINGS') || {};
26
+ nconf_1.default.set('AUTH0_KEYWORD_REPLACE_MAPPINGS', Object.assign(mappings, process.env));
27
+ }
28
+ if (configFile) {
29
+ nconf_1.default.file(configFile);
30
+ }
31
+ const overrides = Object.assign({ AUTH0_INPUT_FILE: inputFile, AUTH0_BASE_PATH: basePath, AUTH0_CONFIG_FILE: configFile, AUTH0_KEYWORD_REPLACE_MAPPINGS: {} }, configObj || {});
32
+ // Prepare configuration by initializing nconf, then passing that as the provider to the config object
33
+ // Allow passed in secret to override the configured one
34
+ if (clientSecret) {
35
+ overrides.AUTH0_CLIENT_SECRET = clientSecret;
36
+ }
37
+ nconf_1.default.overrides(overrides);
38
+ // Setup context and load
39
+ const context = yield (0, context_1.default)(nconf_1.default.get());
40
+ yield context.load();
41
+ const config = (0, configFactory_1.default)();
42
+ config.setProvider((key) => nconf_1.default.get(key));
43
+ yield (0, tools_1.deploy)(context.assets, context.mgmtClient, config);
44
+ logger_1.default.info('Import Successful');
45
+ });
46
+ }
47
+ exports.default = importCMD;