Skip to content

Commit

Permalink
feat: add experimental early access feature
Browse files Browse the repository at this point in the history
command
  • Loading branch information
kushalshit27 committed Feb 3, 2025
1 parent 9766cb7 commit 000b36d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type SharedParams = {
secret?: string;
base_path?: string; // Necessary when package imported as Node module
config?: Partial<Config>;
experimental_ea?: boolean;
};

type ImportSpecificParams = {
Expand Down Expand Up @@ -43,6 +44,12 @@ function getParams(): CliParams {
describe: 'A url for proxying requests, only set this if you are behind a proxy.',
type: 'string',
})
.option('experimental_ea', {
alias: 'ea',
describe: 'This will enable supoort experimental early access of features/resource types.',
type: 'boolean',
default: false,
})
.command(['import', 'deploy'], 'Deploy Configuration', {
input_file: {
alias: 'i',
Expand Down
9 changes: 9 additions & 0 deletions src/commands/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default async function exportCMD(params: ExportParams) {
export_ids: exportIds,
secret: clientSecret,
env: shouldInheritEnv = false,
experimental_ea: experimentalEA,
} = params;

if (shouldInheritEnv) {
Expand Down Expand Up @@ -44,6 +45,14 @@ export default async function exportCMD(params: ExportParams) {
overrides.AUTH0_EXPORT_IDENTIFIERS = exportIds;
}

// Overrides AUTH0_INCLUDE_EXPERIMENTAL_EA is experimental_ea passed in command line
if (experimentalEA) {
overrides.AUTH0_EXPERIMENTAL_EA = experimentalEA;

// nconf.overrides() sometimes doesn't work, so we need to set it manually to ensure it's set
nconf.set('AUTH0_EXPERIMENTAL_EA', experimentalEA);
}

// Check output folder
if (!isDirectory(outputFolder)) {
log.info(`Creating ${outputFolder}`);
Expand Down
9 changes: 9 additions & 0 deletions src/commands/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default async function importCMD(params: ImportParams) {
config: configObj,
env: shouldInheritEnv = false,
secret: clientSecret,
experimental_ea: experimentalEA,
} = params;

if (shouldInheritEnv) {
Expand All @@ -39,6 +40,14 @@ export default async function importCMD(params: ImportParams) {
overrides.AUTH0_CLIENT_SECRET = clientSecret;
}

// Overrides AUTH0_INCLUDE_EXPERIMENTAL_EA is experimental_ea passed in command line
if (experimentalEA) {
overrides.AUTH0_EXPERIMENTAL_EA = experimentalEA;

// nconf.overrides() sometimes doesn't work, so we need to set it manually to ensure it's set
nconf.set('AUTH0_EXPERIMENTAL_EA', experimentalEA);
}

nconf.overrides(overrides);

// Setup context and load
Expand Down
15 changes: 15 additions & 0 deletions src/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const nonPrimitiveProps: (keyof Config)[] = [
'INCLUDED_PROPS',
];

const EA_FEATURES = ['ACUL', 'wewewe'];

export const setupContext = async (
config: Config,
command: 'import' | 'export'
Expand Down Expand Up @@ -132,6 +134,19 @@ export const setupContext = async (
}
})(config);

((config: Config) => {
// Check if experimental early access features are enabled
if (config.AUTH0_EXPERIMENTAL_EA) {
log.warn(
`Experimental early access ${
EA_FEATURES.length === 1
? 'feature [' + EA_FEATURES.join('') + '] is'
: 'features [' + EA_FEATURES.join(',') + '] are'
} enabled. These are in a pre-release state and may change in future release.`
);
}
})(config);

const accessToken = await (async (): Promise<string> => {
const {
AUTH0_DOMAIN,
Expand Down
16 changes: 10 additions & 6 deletions src/tools/auth0/handlers/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,15 @@ export default class PromptsHandler extends DefaultHandler {
partials,
};

try {
const screenRenderers = await this.getPromptScreenSettings();
prompts.screenRenderers = screenRenderers;
} catch (error) {
log.warn(`Unable to fetch screen renderers: ${error}`);
const includeExperimentalEA = this.config('AUTH0_EXPERIMENTAL_EA') || false;

if (includeExperimentalEA) {
try {
const screenRenderers = await this.getPromptScreenSettings();
prompts.screenRenderers = screenRenderers;
} catch (error) {
log.warn(`Unable to fetch screen renderers: ${error}`);
}
}

return prompts;
Expand Down Expand Up @@ -608,7 +612,7 @@ export default class PromptsHandler extends DefaultHandler {
} else {
updatePayload = {
...updatePrams,
rendering_mode
rendering_mode,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export type Config = {
AUTH0_EXCLUDED_CONNECTIONS?: string[];
AUTH0_EXCLUDED_RESOURCE_SERVERS?: string[];
AUTH0_EXCLUDED_DEFAULTS?: string[];
AUTH0_EXPERIMENTAL_EA: boolean;
}; // TODO: replace with a more accurate representation of the Config type

export type Asset = { [key: string]: any };
Expand Down

0 comments on commit 000b36d

Please sign in to comment.