blok0 0.1.1 → 0.1.2

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/dist/index.js CHANGED
@@ -79,7 +79,7 @@ OPTIONS:
79
79
  EXAMPLES:
80
80
  blok0 login
81
81
  blok0 generate starter my-project
82
- blok0 add block https://api.example.com/blocks/123
82
+ blok0 add block https://www.blok0.com/api/cli/sections/123
83
83
 
84
84
  For more information, visit: https://github.com/blok0-payload/cli
85
85
  `);
@@ -132,9 +132,9 @@ async function main() {
132
132
  case 'add':
133
133
  const [addSubcommand, ...addRestArgs] = restArgs;
134
134
  if (addSubcommand === 'block') {
135
- const blockUrl = addRestArgs[0];
135
+ const blockUrl = `https://www.blok0.com/api/cli/sections/${addRestArgs[0]}`;
136
136
  if (!blockUrl) {
137
- console.error('Error: Block URL is required. Use: blok0 add block <url>');
137
+ console.error('Error: Block Slug is required. Use: blok0 add block <slug>');
138
138
  process.exit(1);
139
139
  }
140
140
  const options = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blok0",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI tool for Payload CMS scaffolding",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/detectors.ts CHANGED
@@ -1,22 +1,22 @@
1
- import { existsSync } from 'fs';
2
- import { join } from 'path';
3
-
4
- export function checkEmptyDirectory(): boolean {
5
- const cwd = process.cwd();
6
-
7
- const pkgPath = join(cwd, 'package.json');
8
- const configJs = join(cwd, 'payload.config.js');
9
- const configTs = join(cwd, 'payload.config.ts');
10
-
11
- if (existsSync(pkgPath)) {
12
- console.error('Error: package.json already exists. Please run in an empty directory.');
13
- return false;
14
- }
15
-
16
- if (existsSync(configJs) || existsSync(configTs)) {
17
- console.error('Error: Payload config file already exists. Please run in an empty directory.');
18
- return false;
19
- }
20
-
21
- return true;
22
- }
1
+ import { existsSync } from 'fs';
2
+ import { join } from 'path';
3
+
4
+ export function checkEmptyDirectory(): boolean {
5
+ const cwd = process.cwd();
6
+
7
+ const pkgPath = join(cwd, 'package.json');
8
+ const configJs = join(cwd, 'payload.config.js');
9
+ const configTs = join(cwd, 'payload.config.ts');
10
+
11
+ if (existsSync(pkgPath)) {
12
+ console.error('Error: package.json already exists. Please run in an empty directory.');
13
+ return false;
14
+ }
15
+
16
+ if (existsSync(configJs) || existsSync(configTs)) {
17
+ console.error('Error: Payload config file already exists. Please run in an empty directory.');
18
+ return false;
19
+ }
20
+
21
+ return true;
22
+ }
@@ -1,62 +1,62 @@
1
- import { createInterface } from 'readline';
2
- import { exec, spawn } from 'child_process';
3
- import { promisify } from 'util';
4
-
5
- const execAsync = promisify(exec);
6
-
7
- const repoUrl = 'https://github.com/blok0-payload/starter.git';
8
-
9
- function prompt(question: string): Promise<boolean> {
10
- return new Promise((resolve) => {
11
- const rl = createInterface({
12
- input: process.stdin,
13
- output: process.stdout,
14
- });
15
- rl.question(question, (answer) => {
16
- rl.close();
17
- resolve(answer.toLowerCase().startsWith('y'));
18
- });
19
- });
20
- }
21
-
22
- export async function generateStarter(): Promise<void> {
23
- console.log('Cloning starter repository...');
24
- try {
25
- await execAsync(`git clone --depth 1 ${repoUrl} .`);
26
- console.log('Repository cloned successfully.');
27
- } catch (error) {
28
- throw new Error(`Failed to clone repository: ${error}`);
29
- }
30
-
31
- // Prompt for bun install
32
- const installDeps = await prompt('Run \'bun install\' to install dependencies? (y/n): ');
33
- if (installDeps) {
34
- console.log('Installing dependencies...');
35
- try {
36
- await new Promise<void>((resolve, reject) => {
37
- const child = spawn('bun', ['install'], { stdio: 'inherit' });
38
- child.on('close', (code) => {
39
- if (code === 0) resolve();
40
- else reject(new Error('Failed to install dependencies'));
41
- });
42
- child.on('error', reject);
43
- });
44
- } catch (error) {
45
- console.error('Failed to install dependencies:', error);
46
- }
47
- }
48
-
49
- // Prompt for git init
50
- const initGit = await prompt('Initialize git repository? (y/n): ');
51
- if (initGit) {
52
- console.log('Initializing git repository...');
53
- try {
54
- await execAsync('git init');
55
- console.log('Git repository initialized.');
56
- } catch (error) {
57
- console.error('Failed to initialize git:', error);
58
- }
59
- }
60
-
61
- console.log('Blok0 starter project created successfully!');
62
- }
1
+ import { createInterface } from 'readline';
2
+ import { exec, spawn } from 'child_process';
3
+ import { promisify } from 'util';
4
+
5
+ const execAsync = promisify(exec);
6
+
7
+ const repoUrl = 'https://github.com/blok0-payload/starter.git';
8
+
9
+ function prompt(question: string): Promise<boolean> {
10
+ return new Promise((resolve) => {
11
+ const rl = createInterface({
12
+ input: process.stdin,
13
+ output: process.stdout,
14
+ });
15
+ rl.question(question, (answer) => {
16
+ rl.close();
17
+ resolve(answer.toLowerCase().startsWith('y'));
18
+ });
19
+ });
20
+ }
21
+
22
+ export async function generateStarter(): Promise<void> {
23
+ console.log('Cloning starter repository...');
24
+ try {
25
+ await execAsync(`git clone --depth 1 ${repoUrl} .`);
26
+ console.log('Repository cloned successfully.');
27
+ } catch (error) {
28
+ throw new Error(`Failed to clone repository: ${error}`);
29
+ }
30
+
31
+ // Prompt for bun install
32
+ const installDeps = await prompt('Run \'bun install\' to install dependencies? (y/n): ');
33
+ if (installDeps) {
34
+ console.log('Installing dependencies...');
35
+ try {
36
+ await new Promise<void>((resolve, reject) => {
37
+ const child = spawn('bun', ['install'], { stdio: 'inherit' });
38
+ child.on('close', (code) => {
39
+ if (code === 0) resolve();
40
+ else reject(new Error('Failed to install dependencies'));
41
+ });
42
+ child.on('error', reject);
43
+ });
44
+ } catch (error) {
45
+ console.error('Failed to install dependencies:', error);
46
+ }
47
+ }
48
+
49
+ // Prompt for git init
50
+ const initGit = await prompt('Initialize git repository? (y/n): ');
51
+ if (initGit) {
52
+ console.log('Initializing git repository...');
53
+ try {
54
+ await execAsync('git init');
55
+ console.log('Git repository initialized.');
56
+ } catch (error) {
57
+ console.error('Failed to initialize git:', error);
58
+ }
59
+ }
60
+
61
+ console.log('Blok0 starter project created successfully!');
62
+ }
package/src/index.ts CHANGED
@@ -47,7 +47,7 @@ OPTIONS:
47
47
  EXAMPLES:
48
48
  blok0 login
49
49
  blok0 generate starter my-project
50
- blok0 add block https://api.example.com/blocks/123
50
+ blok0 add block https://www.blok0.com/api/cli/sections/123
51
51
 
52
52
  For more information, visit: https://github.com/blok0-payload/cli
53
53
  `);
@@ -107,9 +107,9 @@ async function main() {
107
107
  case 'add':
108
108
  const [addSubcommand, ...addRestArgs] = restArgs;
109
109
  if (addSubcommand === 'block') {
110
- const blockUrl = addRestArgs[0];
110
+ const blockUrl = `https://www.blok0.com/api/cli/sections/${addRestArgs[0]}`;
111
111
  if (!blockUrl) {
112
- console.error('Error: Block URL is required. Use: blok0 add block <url>');
112
+ console.error('Error: Block Slug is required. Use: blok0 add block <slug>');
113
113
  process.exit(1);
114
114
  }
115
115
  const options = {
package/tsconfig.json CHANGED
@@ -1,16 +1,16 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "commonjs",
5
- "outDir": "./dist",
6
- "rootDir": "./src",
7
- "strict": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "declaration": true,
12
- "resolveJsonModule": true
13
- },
14
- "include": ["src/**/*.ts"],
15
- "exclude": ["node_modules", "dist", "src/templates/**"]
16
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "commonjs",
5
+ "outDir": "./dist",
6
+ "rootDir": "./src",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "declaration": true,
12
+ "resolveJsonModule": true
13
+ },
14
+ "include": ["src/**/*.ts"],
15
+ "exclude": ["node_modules", "dist", "src/templates/**"]
16
+ }