@minnai/create-aura-app 0.0.3 → 0.0.9

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 (2) hide show
  1. package/dist/scaffold.js +56 -17
  2. package/package.json +1 -1
package/dist/scaffold.js CHANGED
@@ -10,52 +10,91 @@ const child_process_1 = require("child_process");
10
10
  const colors_1 = require("kleur/colors");
11
11
  async function scaffold(options) {
12
12
  const { root, template, install, git, projectName } = options;
13
- console.log((0, colors_1.dim)(`\nScaffolding project in ${root}...`));
13
+ console.log((0, colors_1.dim)(`Scaffolding project in ${root}...`));
14
+ console.log((0, colors_1.dim)(`Current working directory: ${process.cwd()}`));
15
+ console.log((0, colors_1.dim)(`PATH: ${process.env.PATH?.substring(0, 100)}...`));
14
16
  // Determine template path
15
- // Assumes templates are in ../templates relative to dist/index.js
16
17
  const templateDir = path_1.default.resolve(__dirname, '..', 'templates', template);
18
+ console.log((0, colors_1.dim)(`Template source: ${templateDir}`));
17
19
  if (!fs_extra_1.default.existsSync(templateDir)) {
20
+ console.error((0, colors_1.red)(`FATAL: Template source does not exist!`));
18
21
  throw new Error(`Template "${template}" not found at ${templateDir}`);
19
22
  }
23
+ // Ensure target directory exists
24
+ try {
25
+ fs_extra_1.default.ensureDirSync(root);
26
+ console.log((0, colors_1.dim)(`Confirmed target directory exists: ${root}`));
27
+ }
28
+ catch (e) {
29
+ console.error((0, colors_1.red)(`Failed to create directory: ${e.message}`));
30
+ }
20
31
  // Copy template files
21
- await fs_extra_1.default.copy(templateDir, root, {
22
- filter: (src) => {
23
- // Filter out node_modules or other unnecessary files if they exist in templates
24
- return !src.includes('node_modules');
32
+ try {
33
+ console.log((0, colors_1.dim)('Copying files...'));
34
+ await fs_extra_1.default.copy(templateDir, root, {
35
+ overwrite: true,
36
+ filter: (src) => {
37
+ return !src.includes('node_modules') && !src.includes('.git');
38
+ }
39
+ });
40
+ // Immediate verification
41
+ const files = fs_extra_1.default.readdirSync(root);
42
+ console.log((0, colors_1.dim)(`Copy complete. Files in target: ${files.join(', ')}`));
43
+ if (files.length === 0) {
44
+ console.error((0, colors_1.red)('WARNING: Target directory is empty after copy!'));
25
45
  }
26
- });
46
+ }
47
+ catch (e) {
48
+ console.error((0, colors_1.red)(`Failed to copy template: ${e.message}`));
49
+ }
27
50
  // Rename _gitignore to .gitignore
28
51
  const gitignorePath = path_1.default.join(root, '_gitignore');
29
52
  if (fs_extra_1.default.existsSync(gitignorePath)) {
30
- await fs_extra_1.default.move(gitignorePath, path_1.default.join(root, '.gitignore'));
53
+ await fs_extra_1.default.move(gitignorePath, path_1.default.join(root, '.gitignore'), { overwrite: true });
54
+ console.log((0, colors_1.dim)('Restored .gitignore'));
31
55
  }
32
56
  // Update package.json name
33
57
  const pkgPath = path_1.default.join(root, 'package.json');
34
58
  if (fs_extra_1.default.existsSync(pkgPath)) {
35
- const pkg = await fs_extra_1.default.readJson(pkgPath);
36
- pkg.name = projectName;
37
- await fs_extra_1.default.writeJson(pkgPath, pkg, { spaces: 2 });
59
+ try {
60
+ const pkg = await fs_extra_1.default.readJson(pkgPath);
61
+ pkg.name = projectName;
62
+ await fs_extra_1.default.writeJson(pkgPath, pkg, { spaces: 2 });
63
+ console.log((0, colors_1.dim)(`Updated package.json name to ${projectName}`));
64
+ }
65
+ catch (e) {
66
+ console.error((0, colors_1.red)(`Failed to update package.json: ${e.message}`));
67
+ }
68
+ }
69
+ else {
70
+ console.warn((0, colors_1.yellow)(`Warning: No package.json found at ${pkgPath}`));
38
71
  }
39
72
  // Initialize Git
40
73
  if (git) {
41
74
  try {
42
- (0, child_process_1.execSync)('git init', { cwd: root, stdio: 'ignore', shell: true });
43
- (0, child_process_1.execSync)('git add -A', { cwd: root, stdio: 'ignore', shell: true });
44
- (0, child_process_1.execSync)('git commit -m "Initial commit from create-aura-app"', { cwd: root, stdio: 'ignore', shell: true });
75
+ console.log((0, colors_1.dim)('Initializing Git...'));
76
+ // Use full path to git if possible, or just rely on shell
77
+ const gitCmd = process.platform === 'win32' ? 'git' : 'git';
78
+ (0, child_process_1.execSync)(`${gitCmd} init`, { cwd: root, stdio: 'ignore', shell: true, env: process.env });
79
+ (0, child_process_1.execSync)(`${gitCmd} add -A`, { cwd: root, stdio: 'ignore', shell: true, env: process.env });
80
+ (0, child_process_1.execSync)(`${gitCmd} commit -m "Initial commit from create-aura-app"`, { cwd: root, stdio: 'ignore', shell: true, env: process.env });
45
81
  console.log((0, colors_1.dim)('Initialized a git repository.'));
46
82
  }
47
83
  catch (e) {
48
- console.warn((0, colors_1.dim)('Git initialization failed. Skipping...'));
84
+ console.warn((0, colors_1.yellow)(`Git initialization skipped: ${e.message}`));
49
85
  }
50
86
  }
51
87
  // Install dependencies
52
88
  if (install) {
53
89
  console.log((0, colors_1.dim)('Installing dependencies... This might take a moment.'));
54
90
  try {
55
- (0, child_process_1.execSync)('npm install', { cwd: root, stdio: 'inherit', shell: true });
91
+ const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
92
+ (0, child_process_1.execSync)(`${npmCmd} install`, { cwd: root, stdio: 'inherit', shell: true, env: process.env });
93
+ console.log((0, colors_1.green)('Dependencies installed successfully.'));
56
94
  }
57
95
  catch (e) {
58
- console.warn((0, colors_1.dim)('Dependency installation failed. You may need to run npm install manually.'));
96
+ console.error((0, colors_1.red)(`Dependency installation failed: ${e.message}`));
97
+ console.warn((0, colors_1.dim)('You may need to run npm install manually.'));
59
98
  }
60
99
  }
61
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minnai/create-aura-app",
3
- "version": "0.0.3",
3
+ "version": "0.0.9",
4
4
  "description": "Scaffolding tool for new Aura projects",
5
5
  "bin": "dist/index.js",
6
6
  "files": [