Skip to content

Commit 579f0f2

Browse files
committed
chore
1 parent b4102a9 commit 579f0f2

2 files changed

Lines changed: 30 additions & 32 deletions

File tree

src/cmd/create.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,6 @@ import { PackageManagerDetector } from '../templates/package-manager';
66
import { InteractivePrompts } from '../templates/prompts';
77
import { genSystemScriptsJsonFile } from '../scripts/gen';
88

9-
/**
10-
* Parse project name and path from the input string.
11-
* Supports formats like:
12-
* - "my-project" -> name: "my-project", path: "./my-project"
13-
* - "path/to/my-project" -> name: "my-project", path: "./path/to/my-project"
14-
* - "path\\to\\my-project" -> name: "my-project", path: "./path/to/my-project"
15-
*/
16-
function parseProjectNameAndPath(input?: string): { projectName: string; projectPath: string } {
17-
if (!input) {
18-
return { projectName: 'my-ckb-project', projectPath: './my-ckb-project' };
19-
}
20-
21-
const normalizedInput = input.trim();
22-
23-
// Normalize path separators to forward slashes for consistency
24-
const normalizedPath = normalizedInput.replace(/\\/g, '/');
25-
26-
// If input contains path separators, extract the project name from the last part
27-
if (normalizedPath.includes('/')) {
28-
const projectName = path.basename(normalizedPath);
29-
const projectPath = normalizedPath;
30-
return { projectName, projectPath };
31-
}
32-
33-
// If it's just a name, use it as both name and path
34-
return { projectName: normalizedInput, projectPath: `./${normalizedInput}` };
35-
}
36-
379
export interface CreateScriptProjectOptions {
3810
manager?: 'pnpm' | 'yarn' | 'npm';
3911
language?: 'typescript' | 'javascript' | 'ts' | 'js';
@@ -164,3 +136,31 @@ export async function createScriptProject(name?: string, options: CreateScriptPr
164136
process.exit(1);
165137
}
166138
}
139+
140+
/**
141+
* Parse project name and path from the input string.
142+
* Supports formats like:
143+
* - "my-project" -> name: "my-project", path: "./my-project"
144+
* - "path/to/my-project" -> name: "my-project", path: "./path/to/my-project"
145+
* - "path\\to\\my-project" -> name: "my-project", path: "./path/to/my-project"
146+
*/
147+
export function parseProjectNameAndPath(input?: string): { projectName: string; projectPath: string } {
148+
if (!input) {
149+
return { projectName: 'my-ckb-project', projectPath: './my-ckb-project' };
150+
}
151+
152+
const normalizedInput = input.trim();
153+
154+
// Normalize path separators to forward slashes for consistency
155+
const normalizedPath = normalizedInput.replace(/\\/g, '/');
156+
157+
// If input contains path separators, extract the project name from the last part
158+
if (normalizedPath.includes('/')) {
159+
const projectName = path.basename(normalizedPath);
160+
const projectPath = normalizedPath;
161+
return { projectName, projectPath };
162+
}
163+
164+
// If it's just a name, use it as both name and path
165+
return { projectName: normalizedInput, projectPath: `./${normalizedInput}` };
166+
}

src/templates/CREATE_COMMAND_IMPLEMENTATION_PLAN.md renamed to src/templates/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# CKB-JS-VM Create Command Implementation Plan
1+
# offckb Create Command Implementation
22

33
## Overview
44

5-
This document outlines the implementation plan for enhancing the `offckb create` command to generate standalone CKB JavaScript script projects using ckb-js-vm, with focus on maintainability, flexibility, and ease of use.
5+
This document outlines the implementation explanation for enhancing the `offckb create` command to generate standalone CKB JavaScript script projects using ckb-js-vm, with focus on maintainability, flexibility, and ease of use.
66

77
## Requirements
88

@@ -371,5 +371,3 @@ describe('{{CONTRACT_NAME}} contract', () => {
371371
- **Rollout**: Replace existing implementation entirely
372372

373373
---
374-
375-
**Ready for implementation upon approval.**

0 commit comments

Comments
 (0)