Skip to content

Commit 6fc7bd8

Browse files
committed
Merge branch 'DXCDT-859-Extensibility-as-custom-provider-deploy-cli-support' of https://github.com/auth0/auth0-deploy-cli into DXCDT-859-Extensibility-as-custom-provider-deploy-cli-support
2 parents 355b75a + 1936a8d commit 6fc7bd8

16 files changed

Lines changed: 10326 additions & 11299 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ This guide will help you to a working implementation of the Deploy CLI tool used
7070
7171
### Prerequisites
7272

73-
- [Node](https://nodejs.dev/) version 18 or greater
73+
- [Node](https://nodejs.dev/) version 20(v20.18.3) or greater
7474
- [Auth0 Tenant](https://auth0.com/)
7575

7676
### Install the Deploy CLI

docs/v8_MIGRATION_GUIDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
Guide to migrating from `7.x` to `8.x`
44

55
- [General](#general)
6-
- [Node 18 or newer is required](#node-18-or-newer-is-required)
6+
- [Node 20(v20.18.3) or newer is required](#node-20(v20.18.3)-or-newer-is-required)
77
- [Auth0 V4 Migration Guide](https://github.com/auth0/node-auth0/blob/master/v4_MIGRATION_GUIDE.md)
88
- [Management Resources](#management-resources)
99
- [EmailProvider](#emailProvider)
1010
- [Migrations](#migrations)
1111

1212
## General
1313

14-
### Node 18 or newer is required
14+
### Node 20(v20.18.3) or newer is required
1515

16-
Node 18 LTS and newer LTS releases are supported.
16+
Node 20(v20.18.3) LTS and newer LTS releases are supported.
1717

1818
## Management Resources
1919

package-lock.json

Lines changed: 24 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"nconf": "^0.12.1",
4343
"promise-pool-executor": "^1.1.1",
4444
"sanitize-filename": "^1.6.3",
45-
"undici": "^7.3.0",
45+
"undici": "^7.4.0",
4646
"winston": "^3.17.0",
4747
"yargs": "^15.3.1"
4848
},
@@ -70,12 +70,12 @@
7070
"rmdir-sync": "^1.0.1",
7171
"sinon": "^13.0.2",
7272
"sinon-chai": "^3.7.0",
73-
"ts-mocha": "^10.0.0",
74-
"typescript": "^5.7.2",
73+
"ts-mocha": "^10.1.0",
74+
"typescript": "^5.8.2",
7575
"zlib": "^1.0.5"
7676
},
7777
"engines": {
78-
"node": ">= 18"
78+
"node": ">= 20.18.3"
7979
},
8080
"keywords": [
8181
"auth0",

src/commands/export.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,6 @@ export default async function exportCMD(params: ExportParams) {
6868
// Setup context and load
6969
const context = await setupContext(nconf.get(), 'export');
7070
await context.dump();
71-
log.info('Export Successful');
72-
73-
log.info(`
74-
================================================
75-
======= Help us improve Auth0 Deploy CLI =======
76-
================================================
77-
We're on a mission to make Auth0 Deploy CLI the best it can be, and we need YOUR help.
78-
We've put together a brief survey to understand how you use Deploy CLI, what you love about it, and where you think we can do better.
7971

80-
===> https://www.surveymonkey.com/r/LZKMPFN <===
81-
82-
Thank you for helping us make Auth0 Deploy CLI better for everyone!
83-
================================================`);
72+
log.info('Export Successful');
8473
}

src/commands/import.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,4 @@ export default async function importCMD(params: ImportParams) {
6161
await toolsDeploy(context.assets, context.mgmtClient, config);
6262

6363
log.info('Import Successful');
64-
65-
log.info(`
66-
================================================
67-
======= Help us improve Auth0 Deploy CLI =======
68-
================================================
69-
We're on a mission to make Auth0 Deploy CLI the best it can be, and we need YOUR help.
70-
We've put together a brief survey to understand how you use Deploy CLI, what you love about it, and where you think we can do better.
71-
72-
===> https://www.surveymonkey.com/r/LZKMPFN <===
73-
74-
Thank you for helping us make Auth0 Deploy CLI better for everyone!
75-
================================================`);
7664
}

src/context/directory/handlers/clientGrants.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path';
22
import fs from 'fs-extra';
33
import { Client, ResourceServer } from 'auth0';
4-
import { constants } from '../../../tools';
4+
import { constants, keywordReplace } from '../../../tools';
55

66
import {
77
getFiles,
@@ -16,6 +16,7 @@ import DirectoryContext from '..';
1616
import { ParsedAsset } from '../../../types';
1717
import { ClientGrant } from '../../../tools/auth0/handlers/clientGrants';
1818
import { paginate } from '../../../tools/auth0/client';
19+
import { doesHaveKeywordMarker } from '../../../keywordPreservation';
1920

2021
type ParsedClientGrants = ParsedAsset<'clientGrants', ClientGrant[]>;
2122

@@ -71,28 +72,41 @@ async function dump(context: DirectoryContext): Promise<void> {
7172
}
7273

7374
const clientName = (() => {
74-
const associatedClient = allClients.find((client) => {
75-
return client.client_id === grant.client_id;
76-
});
75+
const associatedClient = allClients.find((client) => client.client_id === grant.client_id);
7776

7877
if (associatedClient === undefined) return grant.client_id;
7978

8079
return associatedClient.name;
8180
})();
8281

83-
const apiName = (() => {
84-
const associatedAPI = allResourceServers.find((resourceServer) => {
85-
return resourceServer.identifier === grant.audience;
86-
});
82+
// Convert audience to the API name for readability
83+
const apiName = (grantAudience: string) => {
84+
const associatedAPI = allResourceServers.find(
85+
(resourceServer) => resourceServer.identifier === grantAudience
86+
);
8787

88-
if (associatedAPI === undefined) return grant.audience;
88+
if (associatedAPI === undefined) return grantAudience; // Use the audience if the API is not found
8989

90-
return associatedAPI.name;
91-
})();
90+
return associatedAPI.name; // Use the name of the API
91+
};
9292

93-
const name = sanitize(`${clientName}-${apiName}`);
94-
const grantFile = path.join(grantsFolder, `${name}.json`);
93+
// Replace keyword markers if necessary
94+
const clientNameNonMarker = doesHaveKeywordMarker(clientName, context.mappings)
95+
? keywordReplace(clientName, context.mappings)
96+
: clientName;
97+
const apiAudienceNonMarker = doesHaveKeywordMarker(grant.audience, context.mappings)
98+
? keywordReplace(grant.audience, context.mappings)
99+
: grant.audience;
100+
101+
// Construct the name using non-marker names
102+
const name = sanitize(`${clientNameNonMarker}-${apiName(apiAudienceNonMarker)}`);
95103

104+
// Ensure the name is not empty or invalid
105+
if (!name || name.trim().length === 0) {
106+
throw new Error(`Invalid name generated for client grant: ${JSON.stringify(grant)}`);
107+
}
108+
109+
const grantFile = path.join(grantsFolder, `${name}.json`);
96110
dumpJSON(grantFile, dumpGrant);
97111
});
98112
}

src/keywordPreservation.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,17 @@ export const preserveKeywords = ({
297297
);
298298
}
299299

300+
// Update the clientGrants audience field if it exists
301+
if (updatedRemoteAssets && (updatedRemoteAssets as any).clientGrants) {
302+
for (let i = 0; i < (updatedRemoteAssets as any).clientGrants.length; i++) {
303+
const clientGrant = (updatedRemoteAssets as any).clientGrants[i];
304+
if (clientGrant.audience === remoteValue) {
305+
clientGrant.audience = localValue;
306+
}
307+
(updatedRemoteAssets as any).clientGrants[i] = clientGrant;
308+
}
309+
}
310+
300311
// Two address possibilities are provided to account for cases when there is a keyword
301312
// in the resources's identifier field. When the resource identifier's field is preserved
302313
// on the remote assets tree, it loses its identify, so we'll need to try two addresses:

src/tools/auth0/handlers/connections.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default class ConnectionsHandler extends DefaultAPIHandler {
144144
if (this.existing) return this.existing;
145145

146146
const connections = await paginate<Connection>(this.client.connections.getAll, {
147-
paginate: true,
147+
checkpoint: true,
148148
include_totals: true,
149149
});
150150

@@ -177,7 +177,7 @@ export default class ConnectionsHandler extends DefaultAPIHandler {
177177
});
178178

179179
const existingConnections = await paginate<Connection>(this.client.connections.getAll, {
180-
paginate: true,
180+
checkpoint: true,
181181
include_totals: true,
182182
});
183183

src/tools/auth0/handlers/databases.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export default class DatabaseHandler extends DefaultAPIHandler {
152152

153153
const connections = await paginate<Connection>(this.client.connections.getAll, {
154154
strategy: [GetConnectionsStrategyEnum.auth0],
155-
paginate: true,
155+
checkpoint: true,
156156
include_totals: true,
157157
});
158158
this.existing = connections;
@@ -183,7 +183,7 @@ export default class DatabaseHandler extends DefaultAPIHandler {
183183
this.client.connections.getAll,
184184
{
185185
strategy: [GetConnectionsStrategyEnum.auth0],
186-
paginate: true,
186+
checkpoint: true,
187187
include_totals: true,
188188
}
189189
);

0 commit comments

Comments
 (0)