create-harper 1.4.5 → 1.4.6

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 (3) hide show
  1. package/index.js +2 -79
  2. package/lib/init.js +80 -0
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -1,81 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import * as prompts from '@clack/prompts';
3
- import path from 'node:path';
4
- import { helpMessage } from './lib/constants/helpMessage.js';
5
- import { pkgFromUserAgent } from './lib/pkg/pkgFromUserAgent.js';
6
- import { checkForUpdate } from './lib/steps/checkForUpdate.js';
7
- import { getEnvVars } from './lib/steps/getEnvVars.js';
8
- import { getPackageName } from './lib/steps/getPackageName.js';
9
- import { getProjectName } from './lib/steps/getProjectName.js';
10
- import { getRunAppImmediately } from './lib/steps/getRunAppImmediately.js';
11
- import { getTemplate } from './lib/steps/getTemplate.js';
12
- import { handleExistingDir } from './lib/steps/handleExistingDir.js';
13
- import { helpAgents } from './lib/steps/helpAgents.js';
14
- import { installAndOptionallyStart } from './lib/steps/installAndOptionallyStart.js';
15
- import { parseArgv } from './lib/steps/parseArgv.js';
16
- import { scaffoldProject } from './lib/steps/scaffoldProject.js';
2
+ import { init } from './lib/init.js';
17
3
 
18
- init().catch((e) => {
19
- console.error(e);
20
- });
21
-
22
- async function init() {
23
- const args = parseArgv(process.argv.slice(2));
24
-
25
- if (args.help) {
26
- console.log(helpMessage);
27
- return;
28
- }
29
-
30
- const currentVersion = await checkForUpdate();
31
- if (args.version) {
32
- console.log(`Current version: ${currentVersion}`);
33
- return;
34
- }
35
-
36
- const interactive = args.interactive;
37
-
38
- // Detect AI agent environment for better agent experience (AX)
39
- await helpAgents(interactive);
40
-
41
- const cancel = () => prompts.cancel('Operation cancelled');
42
-
43
- // Get the project name and target directory
44
- const projectNameResult = await getProjectName(args.targetDir, interactive);
45
- if (projectNameResult.cancelled) { return cancel(); }
46
- const { projectName, targetDir } = projectNameResult;
47
-
48
- // Handle if the directory exists and isn't empty
49
- const handleExistingDirResult = await handleExistingDir(targetDir, args.overwrite, interactive);
50
- if (handleExistingDirResult.cancelled) { return cancel(); }
51
-
52
- // Get the package name
53
- const packageNameResult = await getPackageName(targetDir, interactive);
54
- if (packageNameResult.cancelled) { return cancel(); }
55
- const { packageName } = packageNameResult;
56
-
57
- // Choose a framework and variant
58
- const templateResult = await getTemplate(args.template, interactive);
59
- if (templateResult.cancelled) { return cancel(); }
60
- const { template } = templateResult;
61
-
62
- // Get environment variables for .env file
63
- const envVarsResult = await getEnvVars(interactive, template, args.deploymentUsername, args.deploymentURL);
64
- if (envVarsResult.cancelled) { return cancel(); }
65
- const { envVars } = envVarsResult;
66
-
67
- // Should we do a package manager installation?
68
- const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
69
- const pkgManager = pkgInfo ? pkgInfo.name : 'npm';
70
- const immediateResult = await getRunAppImmediately(args.immediate, interactive, pkgManager);
71
- if (immediateResult.cancelled) { return cancel(); }
72
- const { immediate } = immediateResult;
73
-
74
- // Write out the contents based on all prior steps.
75
- const cwd = process.cwd();
76
- const root = path.join(cwd, targetDir);
77
- scaffoldProject(root, projectName, packageName, template, envVars);
78
-
79
- // Log out the next steps.
80
- installAndOptionallyStart(root, pkgManager, immediate, args.skipInstall);
81
- }
4
+ init();
package/lib/init.js ADDED
@@ -0,0 +1,80 @@
1
+ import * as prompts from '@clack/prompts';
2
+ import path from 'node:path';
3
+ import { helpMessage } from './constants/helpMessage.js';
4
+ import { pkgFromUserAgent } from './pkg/pkgFromUserAgent.js';
5
+ import { checkForUpdate } from './steps/checkForUpdate.js';
6
+ import { getEnvVars } from './steps/getEnvVars.js';
7
+ import { getPackageName } from './steps/getPackageName.js';
8
+ import { getProjectName } from './steps/getProjectName.js';
9
+ import { getRunAppImmediately } from './steps/getRunAppImmediately.js';
10
+ import { getTemplate } from './steps/getTemplate.js';
11
+ import { handleExistingDir } from './steps/handleExistingDir.js';
12
+ import { helpAgents } from './steps/helpAgents.js';
13
+ import { installAndOptionallyStart } from './steps/installAndOptionallyStart.js';
14
+ import { parseArgv } from './steps/parseArgv.js';
15
+ import { scaffoldProject } from './steps/scaffoldProject.js';
16
+
17
+ export async function init() {
18
+ try {
19
+ const args = parseArgv(process.argv.slice(2));
20
+
21
+ if (args.help) {
22
+ console.log(helpMessage);
23
+ return;
24
+ }
25
+
26
+ const currentVersion = await checkForUpdate();
27
+ if (args.version) {
28
+ console.log(`Current version: ${currentVersion}`);
29
+ return;
30
+ }
31
+
32
+ const interactive = args.interactive;
33
+
34
+ // Detect AI agent environment for better agent experience (AX)
35
+ await helpAgents(interactive);
36
+
37
+ const cancel = () => prompts.cancel('Operation cancelled');
38
+
39
+ // Get the project name and target directory
40
+ const projectNameResult = await getProjectName(args.targetDir, interactive);
41
+ if (projectNameResult.cancelled) { return cancel(); }
42
+ const { projectName, targetDir } = projectNameResult;
43
+
44
+ // Handle if the directory exists and isn't empty
45
+ const handleExistingDirResult = await handleExistingDir(targetDir, args.overwrite, interactive);
46
+ if (handleExistingDirResult.cancelled) { return cancel(); }
47
+
48
+ // Get the package name
49
+ const packageNameResult = await getPackageName(targetDir, interactive);
50
+ if (packageNameResult.cancelled) { return cancel(); }
51
+ const { packageName } = packageNameResult;
52
+
53
+ // Choose a framework and variant
54
+ const templateResult = await getTemplate(args.template, interactive);
55
+ if (templateResult.cancelled) { return cancel(); }
56
+ const { template } = templateResult;
57
+
58
+ // Get environment variables for .env file
59
+ const envVarsResult = await getEnvVars(interactive, template, args.deploymentUsername, args.deploymentURL);
60
+ if (envVarsResult.cancelled) { return cancel(); }
61
+ const { envVars } = envVarsResult;
62
+
63
+ // Should we do a package manager installation?
64
+ const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
65
+ const pkgManager = pkgInfo ? pkgInfo.name : 'npm';
66
+ const immediateResult = await getRunAppImmediately(args.immediate, interactive, pkgManager);
67
+ if (immediateResult.cancelled) { return cancel(); }
68
+ const { immediate } = immediateResult;
69
+
70
+ // Write out the contents based on all prior steps.
71
+ const cwd = process.cwd();
72
+ const root = path.join(cwd, targetDir);
73
+ scaffoldProject(root, projectName, packageName, template, envVars);
74
+
75
+ // Log out the next steps.
76
+ installAndOptionallyStart(root, pkgManager, immediate, args.skipInstall);
77
+ } catch (e) {
78
+ console.error(e);
79
+ }
80
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-harper",
3
3
  "description": "Scaffold a new Harper project in JavaScript or TypeScript.",
4
- "version": "1.4.5",
4
+ "version": "1.4.6",
5
5
  "type": "module",
6
6
  "author": {
7
7
  "name": "HarperDB",