@cbnventures/nova 0.21.0 → 0.22.0

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 (71) hide show
  1. package/build/package.json +2 -1
  2. package/build/src/cli/generate/github/workflows-blueprint-variables.d.ts.map +1 -1
  3. package/build/src/cli/generate/github/workflows-blueprint-variables.js +7 -7
  4. package/build/src/cli/generate/github/workflows-blueprint-variables.js.map +1 -1
  5. package/build/src/cli/generate/github/workflows-blueprint.d.ts.map +1 -1
  6. package/build/src/cli/generate/github/workflows-blueprint.js +71 -37
  7. package/build/src/cli/generate/github/workflows-blueprint.js.map +1 -1
  8. package/build/src/cli/generate/must-haves/dotenv.d.ts.map +1 -1
  9. package/build/src/cli/generate/must-haves/dotenv.js +9 -8
  10. package/build/src/cli/generate/must-haves/dotenv.js.map +1 -1
  11. package/build/src/cli/recipe/package-json/normalize-dependencies.js +1 -1
  12. package/build/src/cli/recipe/package-json/normalize-dependencies.js.map +1 -1
  13. package/build/src/cli/recipe/package-json/sync-identity.d.ts.map +1 -1
  14. package/build/src/cli/recipe/package-json/sync-identity.js +45 -0
  15. package/build/src/cli/recipe/package-json/sync-identity.js.map +1 -1
  16. package/build/src/cli/utility/changelog.d.ts.map +1 -1
  17. package/build/src/cli/utility/changelog.js +93 -19
  18. package/build/src/cli/utility/changelog.js.map +1 -1
  19. package/build/src/cli/utility/initialize.d.ts.map +1 -1
  20. package/build/src/cli/utility/initialize.js +123 -79
  21. package/build/src/cli/utility/initialize.js.map +1 -1
  22. package/build/src/cli/utility/run-scripts.d.ts.map +1 -1
  23. package/build/src/cli/utility/run-scripts.js +12 -4
  24. package/build/src/cli/utility/run-scripts.js.map +1 -1
  25. package/build/src/cli/utility/transpile.d.ts.map +1 -1
  26. package/build/src/cli/utility/transpile.js +1 -0
  27. package/build/src/cli/utility/transpile.js.map +1 -1
  28. package/build/src/cli/utility/type-check.d.ts.map +1 -1
  29. package/build/src/cli/utility/type-check.js +1 -0
  30. package/build/src/cli/utility/type-check.js.map +1 -1
  31. package/build/src/lib/env-github.d.ts +2 -1
  32. package/build/src/lib/env-github.d.ts.map +1 -1
  33. package/build/src/lib/env-github.js +20 -0
  34. package/build/src/lib/env-github.js.map +1 -1
  35. package/build/src/lib/env-managed-set.d.ts.map +1 -1
  36. package/build/src/lib/env-managed-set.js +28 -22
  37. package/build/src/lib/env-managed-set.js.map +1 -1
  38. package/build/src/lib/env-status.d.ts.map +1 -1
  39. package/build/src/lib/env-status.js +25 -22
  40. package/build/src/lib/env-status.js.map +1 -1
  41. package/build/src/lib/nova-config.d.ts +2 -0
  42. package/build/src/lib/nova-config.d.ts.map +1 -1
  43. package/build/src/lib/nova-config.js +170 -125
  44. package/build/src/lib/nova-config.js.map +1 -1
  45. package/build/src/toolkit/nova-identity.d.ts +4 -2
  46. package/build/src/toolkit/nova-identity.d.ts.map +1 -1
  47. package/build/src/toolkit/nova-identity.js +25 -6
  48. package/build/src/toolkit/nova-identity.js.map +1 -1
  49. package/build/src/types/cli/generate/github/workflows-blueprint-variables.d.ts +6 -6
  50. package/build/src/types/cli/generate/github/workflows-blueprint.d.ts +29 -17
  51. package/build/src/types/cli/generate/must-haves/dotenv.d.ts +11 -9
  52. package/build/src/types/cli/recipe/package-json/sync-identity.d.ts +22 -0
  53. package/build/src/types/cli/utility/changelog.d.ts +32 -0
  54. package/build/src/types/cli/utility/initialize.d.ts +43 -47
  55. package/build/src/types/cli/utility/run-scripts.d.ts +2 -0
  56. package/build/src/types/lib/env-github.d.ts +34 -1
  57. package/build/src/types/lib/env-managed-set.d.ts +9 -9
  58. package/build/src/types/lib/env-status.d.ts +12 -14
  59. package/build/src/types/lib/nova-config.d.ts +110 -69
  60. package/build/src/types/shared.d.ts +167 -57
  61. package/build/src/types/tests/bin-git-tracked.test.d.ts +52 -0
  62. package/build/src/types/tests/cli/generate/github/workflows-blueprint.test.d.ts +10 -10
  63. package/build/src/types/tests/cli/generate/must-haves/dotenv.test.d.ts +40 -0
  64. package/build/src/types/tests/cli/recipe/package-json/sync-identity.test.d.ts +133 -0
  65. package/build/src/types/tests/cli/utility/initialize.test.d.ts +74 -138
  66. package/build/src/types/tests/lib/nova-config.test.d.ts +83 -57
  67. package/build/src/types/tests/toolkit/nova-identity.test.d.ts +102 -0
  68. package/build/src/types/toolkit/nova-identity.d.ts +47 -5
  69. package/build/templates/generators/must-haves/agent-conventions/conventions/typescript.md +12 -12
  70. package/build/templates/scaffold/docs/docusaurus/package.json +2 -2
  71. package/package.json +2 -1
@@ -2503,33 +2503,35 @@ export class Runner {
2503
2503
  static async promptEnvironment(config) {
2504
2504
  while (true) {
2505
2505
  const environment = (config['environment'] !== undefined) ? config['environment'] : {};
2506
- const globalScope = environment['global'];
2507
- const apps = (environment['apps'] !== undefined) ? environment['apps'] : {};
2506
+ const projectScope = environment['project'];
2507
+ const workspacesGroup = (environment['workspaces'] !== undefined) ? environment['workspaces'] : {};
2508
2508
  const workspaces = (config['workspaces'] !== undefined) ? config['workspaces'] : {};
2509
2509
  const appPaths = [];
2510
2510
  for (const workspaceEntry of Object.entries(workspaces)) {
2511
- if (workspaceEntry[1]['role'] === 'app' && appPaths.includes(workspaceEntry[0]) === false) {
2511
+ if ((workspaceEntry[1]['role'] === 'app'
2512
+ || workspaceEntry[0] === './')
2513
+ && appPaths.includes(workspaceEntry[0]) === false) {
2512
2514
  appPaths.push(workspaceEntry[0]);
2513
2515
  }
2514
2516
  }
2515
- for (const appPath of Object.keys(apps)) {
2517
+ for (const appPath of Object.keys(workspacesGroup)) {
2516
2518
  if (appPaths.includes(appPath) === false) {
2517
2519
  appPaths.push(appPath);
2518
2520
  }
2519
2521
  }
2520
2522
  const choices = [];
2521
- const globalVariables = (globalScope !== undefined && globalScope['variables'] !== undefined) ? globalScope['variables'] : [];
2522
- const globalSummary = (globalScope !== undefined) ? `${globalScope['prefix']} · ${globalVariables.length} value(s)` : 'Not configured yet.';
2523
+ const projectVariables = (projectScope !== undefined && projectScope['variables'] !== undefined) ? projectScope['variables'] : [];
2524
+ const projectSummary = (projectScope !== undefined) ? `${projectScope['prefix']} · ${projectVariables.length} value(s)` : 'Not configured yet.';
2523
2525
  choices.push({
2524
- title: 'Global keys',
2525
- description: globalSummary,
2526
+ title: 'Project keys',
2527
+ description: projectSummary,
2526
2528
  value: {
2527
2529
  kind: 'scope',
2528
- scope: 'global',
2530
+ scope: 'project',
2529
2531
  },
2530
2532
  });
2531
2533
  for (const appPath of appPaths) {
2532
- const appScope = apps[appPath];
2534
+ const appScope = workspacesGroup[appPath];
2533
2535
  const appVariables = (appScope !== undefined && appScope['variables'] !== undefined) ? appScope['variables'] : [];
2534
2536
  const appSummary = (appScope !== undefined) ? `${appScope['prefix']} · ${appVariables.length} value(s)` : 'Not configured yet.';
2535
2537
  choices.push({
@@ -2537,7 +2539,7 @@ export class Runner {
2537
2539
  description: appSummary,
2538
2540
  value: {
2539
2541
  kind: 'scope',
2540
- scope: 'app',
2542
+ scope: 'workspace',
2541
2543
  appPath,
2542
2544
  },
2543
2545
  });
@@ -2595,9 +2597,9 @@ export class Runner {
2595
2597
  }
2596
2598
  static async readLocalFilledKeys(config) {
2597
2599
  const environment = config['environment'] ?? {};
2598
- const apps = environment['apps'] ?? {};
2600
+ const workspaces = environment['workspaces'] ?? {};
2599
2601
  const result = {};
2600
- for (const appPath of Object.keys(apps)) {
2602
+ for (const appPath of Object.keys(workspaces)) {
2601
2603
  const filled = [];
2602
2604
  const envPath = join(process.cwd(), appPath, '.env');
2603
2605
  try {
@@ -2710,44 +2712,44 @@ export class Runner {
2710
2712
  return confirmOutput['result'].confirm === true;
2711
2713
  }
2712
2714
  static async promptEnvironmentScope(config, options) {
2713
- const isApp = options['scope'] === 'app';
2715
+ const isWorkspace = options['scope'] === 'workspace';
2714
2716
  const appPath = options['appPath'];
2715
2717
  const environment = (config['environment'] !== undefined) ? config['environment'] : {};
2716
- const existingApps = (environment['apps'] !== undefined) ? environment['apps'] : {};
2717
- const existingBlock = (isApp === true && appPath !== undefined) ? existingApps[appPath] : environment['global'];
2718
+ const existingWorkspaces = (environment['workspaces'] !== undefined) ? environment['workspaces'] : {};
2719
+ const existingBlock = (isWorkspace === true && appPath !== undefined) ? existingWorkspaces[appPath] : environment['project'];
2718
2720
  let prefix = (existingBlock !== undefined) ? existingBlock['prefix'] : '';
2719
2721
  const variables = (existingBlock !== undefined && existingBlock['variables'] !== undefined) ? [...existingBlock['variables']] : [];
2720
2722
  const sync = () => {
2721
- const hasContent = prefix !== '' || variables.length > 0;
2723
+ const hasContent = prefix !== '';
2722
2724
  const nextEnvironment = (config['environment'] !== undefined) ? config['environment'] : {};
2723
- if (isApp === true && appPath !== undefined) {
2724
- const nextApps = (nextEnvironment['apps'] !== undefined) ? nextEnvironment['apps'] : {};
2725
+ if (isWorkspace === true && appPath !== undefined) {
2726
+ const nextWorkspaces = (nextEnvironment['workspaces'] !== undefined) ? nextEnvironment['workspaces'] : {};
2725
2727
  if (hasContent === true) {
2726
- const appBlock = { prefix };
2728
+ const workspaceBlock = { prefix };
2727
2729
  if (variables.length > 0) {
2728
- Object.assign(appBlock, { variables: [...variables] });
2730
+ Object.assign(workspaceBlock, { variables: [...variables] });
2729
2731
  }
2730
- Reflect.set(nextApps, appPath, appBlock);
2732
+ Reflect.set(nextWorkspaces, appPath, workspaceBlock);
2731
2733
  }
2732
2734
  else {
2733
- Reflect.deleteProperty(nextApps, appPath);
2735
+ Reflect.deleteProperty(nextWorkspaces, appPath);
2734
2736
  }
2735
- if (Object.keys(nextApps).length > 0) {
2736
- Object.assign(nextEnvironment, { apps: nextApps });
2737
+ if (Object.keys(nextWorkspaces).length > 0) {
2738
+ Object.assign(nextEnvironment, { workspaces: nextWorkspaces });
2737
2739
  }
2738
2740
  else {
2739
- Reflect.deleteProperty(nextEnvironment, 'apps');
2741
+ Reflect.deleteProperty(nextEnvironment, 'workspaces');
2740
2742
  }
2741
2743
  }
2742
2744
  else if (hasContent === true) {
2743
- const globalBlock = { prefix };
2745
+ const projectBlock = { prefix };
2744
2746
  if (variables.length > 0) {
2745
- Object.assign(globalBlock, { variables: [...variables] });
2747
+ Object.assign(projectBlock, { variables: [...variables] });
2746
2748
  }
2747
- Object.assign(nextEnvironment, { global: globalBlock });
2749
+ Object.assign(nextEnvironment, { project: projectBlock });
2748
2750
  }
2749
2751
  else {
2750
- Reflect.deleteProperty(nextEnvironment, 'global');
2752
+ Reflect.deleteProperty(nextEnvironment, 'project');
2751
2753
  }
2752
2754
  if (Object.keys(nextEnvironment).length > 0) {
2753
2755
  Object.assign(config, { environment: nextEnvironment });
@@ -2772,7 +2774,7 @@ export class Runner {
2772
2774
  if (variable === undefined) {
2773
2775
  continue;
2774
2776
  }
2775
- const variableKind = (variable['secret'] === true) ? 'secret' : 'variable';
2777
+ const variableKind = ('secret' in variable && variable['secret'] === true) ? 'secret' : 'variable';
2776
2778
  const variableLabel = `${variable['key']} (${variableKind})`;
2777
2779
  choices.push({
2778
2780
  title: `${chalk.yellow.bold('[EDIT]')} ${variableLabel}`,
@@ -2808,7 +2810,7 @@ export class Runner {
2808
2810
  const menuOutput = await Runner.promptWithCancel({
2809
2811
  type: 'select',
2810
2812
  name: 'action',
2811
- message: (isApp === true && appPath !== undefined) ? `Manage environment for "${appPath}".` : 'Manage the global environment namespace.',
2813
+ message: (isWorkspace === true && appPath !== undefined) ? `Manage environment for "${appPath}".` : 'Manage the project environment namespace.',
2812
2814
  choices,
2813
2815
  });
2814
2816
  if (menuOutput['cancelled'] === true) {
@@ -2856,7 +2858,16 @@ export class Runner {
2856
2858
  continue;
2857
2859
  }
2858
2860
  if (menuOutputResultValue.action['kind'] === 'add') {
2859
- const addValue = await Runner.promptEnvironmentValueForm(undefined, isApp);
2861
+ if (prefix === '') {
2862
+ Logger.customize({
2863
+ name: 'Runner.promptEnvironmentScope',
2864
+ purpose: 'prefixRequired',
2865
+ padTop: 1,
2866
+ padBottom: 1,
2867
+ }).error('Set a prefix for this namespace before adding values.');
2868
+ continue;
2869
+ }
2870
+ const addValue = await Runner.promptEnvironmentValueForm(undefined, isWorkspace);
2860
2871
  if (addValue === undefined) {
2861
2872
  continue;
2862
2873
  }
@@ -2875,7 +2886,7 @@ export class Runner {
2875
2886
  if (editIndex < 0 || editIndex >= variables.length) {
2876
2887
  continue;
2877
2888
  }
2878
- const editValue = await Runner.promptEnvironmentValueForm(variables[editIndex], isApp);
2889
+ const editValue = await Runner.promptEnvironmentValueForm(variables[editIndex], isWorkspace);
2879
2890
  if (editValue === undefined) {
2880
2891
  continue;
2881
2892
  }
@@ -2935,7 +2946,7 @@ export class Runner {
2935
2946
  }
2936
2947
  }
2937
2948
  }
2938
- static async promptEnvironmentValueForm(existing, isApp) {
2949
+ static async promptEnvironmentValueForm(existing, isWorkspace) {
2939
2950
  const keyOutput = await Runner.promptWithCancel({
2940
2951
  type: 'text',
2941
2952
  name: 'key',
@@ -2956,47 +2967,92 @@ export class Runner {
2956
2967
  }).error(`The key "${key}" is not a legal GitHub name. Use letters, digits, and underscores, and do not start with a digit or "GITHUB_".`);
2957
2968
  return undefined;
2958
2969
  }
2959
- const secretOutput = await Runner.promptWithCancel({
2960
- type: 'confirm',
2961
- name: 'secret',
2962
- message: 'Store as a GitHub Secret (encrypted)? Choose no for a Variable (plaintext).',
2963
- initial: (existing !== undefined) ? existing['secret'] : true,
2964
- });
2965
- if (secretOutput['cancelled'] === true) {
2966
- return undefined;
2970
+ let reach = 'managed';
2971
+ if (isWorkspace === true) {
2972
+ const reachValues = [
2973
+ 'local',
2974
+ 'managed',
2975
+ 'build',
2976
+ 'runtime',
2977
+ ];
2978
+ let reachInitial = reachValues.indexOf('build');
2979
+ if (existing !== undefined) {
2980
+ const existingReachIndex = reachValues.indexOf(existing['reach']);
2981
+ if (existingReachIndex !== -1) {
2982
+ reachInitial = existingReachIndex;
2983
+ }
2984
+ }
2985
+ const reachOutput = await Runner.promptWithCancel({
2986
+ type: 'select',
2987
+ name: 'reach',
2988
+ message: 'Where does this value travel?',
2989
+ choices: [
2990
+ {
2991
+ title: 'local (.env only, never GitHub)',
2992
+ value: 'local',
2993
+ },
2994
+ {
2995
+ title: 'managed (GitHub only, delivered nowhere)',
2996
+ value: 'managed',
2997
+ },
2998
+ {
2999
+ title: 'build (GitHub, baked into the build)',
3000
+ value: 'build',
3001
+ },
3002
+ {
3003
+ title: 'runtime (GitHub, synced to the server)',
3004
+ value: 'runtime',
3005
+ },
3006
+ ],
3007
+ initial: reachInitial,
3008
+ });
3009
+ if (reachOutput['cancelled'] === true) {
3010
+ return undefined;
3011
+ }
3012
+ reach = reachOutput['result'].reach;
2967
3013
  }
2968
- const secret = secretOutput['result'].secret === true;
2969
- const value = {
2970
- key,
2971
- secret,
2972
- };
2973
- if (isApp === true) {
2974
- const buildOnlyOutput = await Runner.promptWithCancel({
3014
+ const isLocal = reach === 'local';
3015
+ let secret = false;
3016
+ if (isLocal === false) {
3017
+ let secretInitial = true;
3018
+ if (existing !== undefined && 'secret' in existing) {
3019
+ secretInitial = existing['secret'];
3020
+ }
3021
+ const secretOutput = await Runner.promptWithCancel({
2975
3022
  type: 'confirm',
2976
- name: 'buildOnly',
2977
- message: 'Deliver only to the build (.env)? Choose no to sync it to the running server.',
2978
- initial: (existing !== undefined && existing['buildOnly'] !== undefined) ? existing['buildOnly'] : true,
3023
+ name: 'secret',
3024
+ message: 'Store as a GitHub Secret (encrypted)? Choose no for a Variable (plaintext).',
3025
+ initial: secretInitial,
2979
3026
  });
2980
- if (buildOnlyOutput['cancelled'] === true) {
3027
+ if (secretOutput['cancelled'] === true) {
2981
3028
  return undefined;
2982
3029
  }
2983
- Object.assign(value, {
2984
- buildOnly: buildOnlyOutput['result'].buildOnly === true,
2985
- });
3030
+ secret = secretOutput['result'].secret === true;
2986
3031
  }
2987
- if (secret === false) {
3032
+ const value = {
3033
+ key,
3034
+ reach,
3035
+ };
3036
+ if (isLocal === false) {
3037
+ Reflect.set(value, 'secret', secret);
3038
+ }
3039
+ if (reach !== 'managed' && secret === false) {
3040
+ let defaultValueInitial = '';
3041
+ if (existing !== undefined
3042
+ && 'defaultValue' in existing
3043
+ && existing['defaultValue'] !== undefined) {
3044
+ defaultValueInitial = existing['defaultValue'];
3045
+ }
2988
3046
  const defaultValueOutput = await Runner.promptWithCancel({
2989
3047
  type: 'text',
2990
3048
  name: 'defaultValue',
2991
3049
  message: 'Default value for the committed ".env.sample" (optional):',
2992
- initial: (existing !== undefined && existing['defaultValue'] !== undefined) ? existing['defaultValue'] : '',
3050
+ initial: defaultValueInitial,
2993
3051
  });
2994
3052
  if (defaultValueOutput['cancelled'] === false) {
2995
3053
  const defaultValue = defaultValueOutput['result'].defaultValue.trim();
2996
3054
  if (defaultValue !== '') {
2997
- Object.assign(value, {
2998
- defaultValue,
2999
- });
3055
+ Reflect.set(value, 'defaultValue', defaultValue);
3000
3056
  }
3001
3057
  }
3002
3058
  }
@@ -3213,22 +3269,6 @@ export class Runner {
3213
3269
  action: 'back',
3214
3270
  };
3215
3271
  }
3216
- const validateWorkspaceDisplayName = (workspaceDisplayNameValue) => {
3217
- return Runner.normalizeText(workspaceDisplayNameValue, Infinity)['result'];
3218
- };
3219
- const displayNamePrompt = await Runner.promptWithCancel({
3220
- type: 'text',
3221
- name: 'workspaceDisplayName',
3222
- message: 'Workspace display name (optional)',
3223
- initial: (options['existingWorkspace'] !== undefined) ? options['existingWorkspace']['displayName'] ?? '' : '',
3224
- validate: validateWorkspaceDisplayName,
3225
- });
3226
- if (displayNamePrompt['cancelled'] === true) {
3227
- return {
3228
- action: 'back',
3229
- };
3230
- }
3231
- const workspaceDisplayNameInput = Runner.normalizeText(displayNamePrompt['result'].workspaceDisplayName, Infinity)['sanitized'];
3232
3272
  const existingRecipes = options['existingPackageJsonRecipes'];
3233
3273
  const recipesPrompt = await Runner.promptWithCancel({
3234
3274
  type: 'multiselect',
@@ -3271,6 +3311,11 @@ export class Runner {
3271
3311
  value: 'keywords',
3272
3312
  selected: existingSettings !== undefined && existingSettings['keywords'] === true,
3273
3313
  },
3314
+ {
3315
+ title: 'displayName',
3316
+ value: 'displayName',
3317
+ selected: existingSettings !== undefined && existingSettings['displayName'] === true,
3318
+ },
3274
3319
  ],
3275
3320
  });
3276
3321
  if (identitySettingsPrompt['cancelled'] === true) {
@@ -3478,7 +3523,6 @@ export class Runner {
3478
3523
  action: 'apply',
3479
3524
  workspace: {
3480
3525
  name: resolvedName,
3481
- ...(workspaceDisplayNameInput !== undefined) ? { displayName: workspaceDisplayNameInput } : {},
3482
3526
  role: selectedRole,
3483
3527
  policy: selectedPolicy,
3484
3528
  },