create-pb-app 1.0.7 → 1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pb-app",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "create-pb-app": "./src/cli.js"
package/src/cli.js CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { mkdirSync, writeFileSync } from 'fs';
3
+ import { mkdirSync, writeFileSync, readFileSync, copyFileSync } from 'fs';
4
4
  import { join, dirname } from 'path';
5
+ import { fileURLToPath } from 'url';
5
6
  import { execSync } from 'child_process';
6
- import { createInterface } from 'readline';
7
7
  import { getTemplates } from './templates.js';
8
8
 
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+
9
11
  // ANSI colors
10
12
  const bold = (s) => `\x1b[1m${s}\x1b[0m`;
11
13
  const green = (s) => `\x1b[32m${s}\x1b[0m`;
@@ -71,35 +73,38 @@ for (const { filePath, content } of templates) {
71
73
  console.log(` ${green('+')} ${filePath}`);
72
74
  }
73
75
 
76
+ // Copy binary assets
77
+ const fontDir = join(projectDir, 'public', 'fonts');
78
+ mkdirSync(fontDir, { recursive: true });
79
+ copyFileSync(
80
+ join(__dirname, 'assets', 'fonts', 'NeueMontreal.woff2'),
81
+ join(fontDir, 'NeueMontreal.woff2')
82
+ );
83
+ console.log(` ${green('+')} public/fonts/NeueMontreal.woff2`);
84
+
74
85
  console.log();
75
- console.log(green(`Created ${templates.length} files.`));
86
+ console.log(green(`Created ${templates.length + 1} files.`));
76
87
  console.log();
77
88
 
78
- async function promptInstall() {
79
- if (skipInstall) return false;
80
-
81
- return new Promise((resolve) => {
82
- const rl = createInterface({
83
- input: process.stdin,
84
- output: process.stdout
85
- });
86
-
87
- rl.question('Install dependencies? (Y/n) ', (answer) => {
88
- rl.close();
89
- const a = answer.trim().toLowerCase();
90
- resolve(a === '' || a === 'y' || a === 'yes');
91
- });
92
- });
93
- }
94
-
95
- const shouldInstall = await promptInstall();
96
-
97
- if (shouldInstall) {
98
- console.log();
99
- console.log(dim('Running npm install...'));
89
+ if (!skipInstall) {
90
+ console.log(dim('Installing dependencies...'));
100
91
  console.log();
101
92
  try {
102
- execSync('npm install', { cwd: projectDir, stdio: 'inherit' });
93
+ execSync('npm install', { cwd: projectDir, stdio: 'pipe' });
94
+
95
+ // Read installed versions from package-lock.json
96
+ const lockPath = join(projectDir, 'package-lock.json');
97
+ const lock = JSON.parse(readFileSync(lockPath, 'utf-8'));
98
+ const pkgJson = JSON.parse(readFileSync(join(projectDir, 'package.json'), 'utf-8'));
99
+
100
+ const allDeps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
101
+ for (const name of Object.keys(allDeps)) {
102
+ const version = lock.packages?.[`node_modules/${name}`]?.version;
103
+ if (version) {
104
+ console.log(` ${green('+')} ${name} ${dim(`v${version}`)}`);
105
+ }
106
+ }
107
+
103
108
  console.log();
104
109
  console.log(green('Dependencies installed.'));
105
110
  } catch {
@@ -111,7 +116,7 @@ console.log();
111
116
  console.log(bold('Done! Next steps:'));
112
117
  console.log();
113
118
  console.log(` ${cyan(`cd ${projectName}`)}`);
114
- if (!shouldInstall) {
119
+ if (skipInstall) {
115
120
  console.log(` ${cyan('npm install')}`);
116
121
  }
117
122
  console.log(` ${cyan('npm run dev')}`);
package/src/templates.js CHANGED
@@ -13,7 +13,8 @@ export function getTemplates(projectName) {
13
13
  type: 'module',
14
14
  scripts: {
15
15
  dev: 'vite',
16
- build: 'vite build'
16
+ build: 'vite build',
17
+ prebuild: 'chmod +x node_modules/.bin/*'
17
18
  },
18
19
  dependencies: {
19
20
  'components-test-pb': 'latest',
@@ -59,6 +60,13 @@ export default defineConfig({});
59
60
  <meta charset="UTF-8">
60
61
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
61
62
  <title>${projectName}</title>
63
+ <style>
64
+ @font-face {
65
+ font-family: 'Neue Montreal';
66
+ src: url('/fonts/NeueMontreal.woff2') format('woff2');
67
+ font-display: swap;
68
+ }
69
+ </style>
62
70
  </head>
63
71
 
64
72
  <body>