@docupace/pipeline 1.0.33-matttest.3 → 1.0.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.33-matttest.3",
3
+ "version": "1.0.33",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,7 +17,8 @@
17
17
  "dependencies": {
18
18
  "@changesets/cli": "^2.27.10",
19
19
  "@docupace/core-client": "^0.1.59",
20
- "auth0-deploy-cli": "^7.24.3",
20
+ "@docupace/pipeline": "^1.0.33-alpha-2",
21
+ "auth0-deploy-cli": "^8.8.0",
21
22
  "axios": "^1.7.9",
22
23
  "commander": "^12.1.0",
23
24
  "dotenv": "^16.4.7",
@@ -1,75 +1,72 @@
1
1
  import axios from 'axios';
2
2
 
3
- import {
4
- createAlias
5
- } from '../next/alias.js';
3
+ import { createAlias } from '../next/alias.js';
6
4
 
7
- import {getAuth0AuthToken} from './configure.js';
5
+ import { getAuth0AuthToken } from './configure.js';
8
6
 
9
- import {
10
- getVaultSecrets,
11
- } from './vault.js';
7
+ import { getVaultSecrets } from './vault.js';
12
8
 
13
- import {
14
- getVaultSecretsConfigs,
15
- } from '../next/config.js';
9
+ import { getVaultSecretsConfigs } from '../next/config.js';
16
10
 
17
- import {
18
- cloneEnvRepository,
19
- readDeployConfig,
20
- } from '../next/deploy.js';
11
+ import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
21
12
 
22
- export async function getCCAlias ({application, auth0Domain, auth0AuthToken}){
13
+ export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
23
14
  console.log(`Forming alias name for application ${application}...`);
24
15
 
25
16
  try {
26
- const auth0Response = await axios.get(`https://${auth0Domain}/api/v2/clients`, {
27
- headers: {authorization: `Bearer ${auth0AuthToken}`},
28
- });
29
-
30
- const appAuth0ClientIdData = auth0Response.data.find(client => client.name === `${application}`);
17
+ const auth0Response = await axios.get(
18
+ `https://${auth0Domain}/api/v2/clients`,
19
+ {
20
+ headers: { authorization: `Bearer ${auth0AuthToken}` },
21
+ },
22
+ );
23
+
24
+ const appAuth0ClientIdData = auth0Response.data.find(
25
+ (client) => client.name === `${application}`,
26
+ );
31
27
  const appAuth0ClientId = appAuth0ClientIdData.client_id;
32
28
 
33
29
  console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
34
30
  return `${appAuth0ClientId}@clients`;
35
31
  } catch (err) {
36
- console.error(`Failed to form alias name for application: ${application}: ${err.message}`);
32
+ console.error(
33
+ `Failed to form alias name for application: ${application}: ${err.message}`,
34
+ );
37
35
  }
38
36
  }
39
37
 
40
38
  export async function configureAlias(site, env, username, password, realm) {
41
-
42
39
  console.log(`Creating alias for site: ${site} in env: ${env}`);
43
-
44
- const commonSecretsPath = getVaultSecretsConfigs(site).commonSecretsPath;
45
- console.log(`commonSecretsPath => ${commonSecretsPath}`)
46
- const commonSecrets = await getVaultSecrets(commonSecretsPath);
47
-
48
40
  // Site Common Secrets
49
- const siteCommonSecretsPath = getVaultSecretsConfigs(site).siteCommonSecretsPath;
50
- console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`)
41
+ const siteCommonSecretsPath =
42
+ getVaultSecretsConfigs(site).siteCommonSecretsPath;
43
+ console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
51
44
  const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
52
45
 
53
- const auth0Domain = `docupace-${env}-${site}.us.auth0.com`
46
+ const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
54
47
  const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
55
48
  const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
56
- const auth0Token = await getAuth0AuthToken(auth0Domain, auth0ClientId, auth0ClientSecret);
49
+ const auth0Token = await getAuth0AuthToken(
50
+ auth0Domain,
51
+ auth0ClientId,
52
+ auth0ClientSecret,
53
+ );
57
54
 
58
55
  await cloneEnvRepository(env);
59
56
 
60
- const { deployConfig: deployGraphQLServerConfig} = await readDeployConfig('graphql-server', env, site, 'values');
57
+ const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
58
+ 'graphql-server',
59
+ env,
60
+ site,
61
+ 'values',
62
+ );
61
63
  const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
62
64
 
63
65
  const clientCredentialsAlias = await getCCAlias({
64
66
  application: 'docupace-graphql-client-credentials',
65
67
  auth0Domain: auth0Domain,
66
- auth0AuthToken: auth0Token
68
+ auth0AuthToken: auth0Token,
67
69
  });
68
70
 
69
- await createAlias(
70
- coreUrl,
71
- username,
72
- password,
73
- realm,
74
- clientCredentialsAlias);
71
+ await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
75
72
  }
package/src/auth0/cli.js CHANGED
@@ -1,34 +1,53 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { Command } from 'commander';
4
- import {
5
- configureFromSite
6
- } from './configure.js';
7
- import {
8
- getVaultSecrets
9
- } from './vault.js'
4
+ import { configureFromSite } from './configure.js';
5
+ import { getVaultSecrets } from './vault.js';
10
6
 
11
7
  import dotenv from 'dotenv';
12
- import {
13
- configureAlias
14
- } from "./alias.js";
8
+ import { configureAlias } from './alias.js';
9
+ import { exportConf } from './export.js';
10
+ import { getAuth0Metadata } from './metadata.js';
15
11
 
16
12
  dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
17
13
 
18
14
  const program = new Command();
19
15
 
20
16
  program
21
- .command('configureFromSite <fromSite> <toSite> <fromEnv> <toEnv> <deployUI> <deployGraphQLServer> <useNewDomain> <configureMFA>')
22
- .description('Configure the Auth0 tenants in env for the given site')
23
- .action(async (fromSite, toSite, fromEnv,toEnv, deployUI, deployGraphQLServer, useNewDomain, configureMFA) => {
24
- await configureFromSite(fromSite, toSite, fromEnv, toEnv, deployUI, deployGraphQLServer, useNewDomain, configureMFA);
25
- });
17
+ .command(
18
+ 'configureFromSite <fromSite> <toSite> <fromEnv> <toEnv> <deployUI> <deployGraphQLServer> <useNewDomain> <useS3>',
19
+ )
20
+ .description('Configure the Auth0 tenants in env for the given site')
21
+ .action(
22
+ async (
23
+ fromSite,
24
+ toSite,
25
+ fromEnv,
26
+ toEnv,
27
+ deployUI,
28
+ deployGraphQLServer,
29
+ useNewDomain,
30
+ useS3,
31
+ ) => {
32
+ await configureFromSite(
33
+ fromSite,
34
+ toSite,
35
+ fromEnv,
36
+ toEnv,
37
+ deployUI,
38
+ deployGraphQLServer,
39
+ useNewDomain,
40
+ useS3 === 'true' || useS3 === true,
41
+ );
42
+ },
43
+ );
26
44
 
27
45
  program
28
46
  .command('getVaultSecrets <vaultPath>')
29
47
  .description('Get Secrets for Vault PATH')
30
48
  .action(async (vaultPath) => {
31
- await getVaultSecrets(vaultPath);
49
+ const data = await getVaultSecrets(vaultPath);
50
+ console.log(JSON.stringify(data, 'null', 2));
32
51
  });
33
52
 
34
53
  program
@@ -38,4 +57,18 @@ program
38
57
  await configureAlias(site, env, username, password, realm);
39
58
  });
40
59
 
60
+ program
61
+ .command('exportConf <site> <env>')
62
+ .description('Export Auth0 configuration for the given site')
63
+ .action(async (site, env) => {
64
+ await exportConf(site, env);
65
+ });
66
+
67
+ program
68
+ .command('getAuth0Metadata <site> <env>')
69
+ .description('Get Auth0 metadata for the given site')
70
+ .action(async (site, env) => {
71
+ await getAuth0Metadata(site, env);
72
+ });
73
+
41
74
  program.parse(process.argv);