@joripspace/cli 0.5.0 → 0.5.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.
@@ -0,0 +1,185 @@
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
+ const { spawnSync } = require('node:child_process');
4
+ const { buildGithubWorkflow } = require('../vendor/core/onboarding.cjs');
5
+ const { resolveProjectFileTarget } = require('./project-paths');
6
+
7
+ function createGithubCommands({ apiRequest, output, projectAuth, projectWorkspaceDir, requireProjectId, stringFlag, writeTextAtomically }) {
8
+ return async function githubCommand(rest, flags) {
9
+ const subcommand = rest[0] || '';
10
+ if (subcommand !== 'prepare') throw new Error('github command requires: prepare');
11
+ if (rest.length > 1) throw new Error('github prepare accepts no positional arguments');
12
+
13
+ const project = requireProjectId(flags);
14
+ const workspace = projectWorkspaceDir(flags);
15
+ const details = await apiRequest(flags, `/v1/projects/${encodeURIComponent(project)}`, {
16
+ method: 'GET',
17
+ ...projectAuth(flags),
18
+ });
19
+ const deployment = details?.deployment;
20
+ if (!deployment || deployment.mode !== 'github_actions') {
21
+ throw commandError('github_connection_required', '이 프로젝트에는 GitHub 저장소가 연결되어 있지 않습니다.');
22
+ }
23
+ const repository = String(deployment.repository || '').trim();
24
+ const branch = String(deployment.branch || '').trim();
25
+ const connectionId = String(deployment.connection_id || '').trim();
26
+ const workflowPath = String(deployment.workflow_path || '').trim();
27
+ if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repository)) {
28
+ throw commandError('github_repository_invalid', '연결된 GitHub 저장소 정보가 올바르지 않습니다.');
29
+ }
30
+ if (!validGitBranch(branch) || !connectionId || !/^\.github\/workflows\/joripspace-[a-z0-9_-]+\.ya?ml$/u.test(workflowPath)) {
31
+ throw commandError('github_connection_invalid', '연결된 GitHub 배포 설정이 올바르지 않습니다.');
32
+ }
33
+ assertMatchingGitWorkspace(workspace, repository, branch);
34
+
35
+ const workflowConfig = inferWorkflowConfig(workspace, flags, stringFlag);
36
+ const workflow = buildGithubWorkflow({
37
+ projectId: details.project_slug || details.project_id || project,
38
+ branch,
39
+ triggerType: deployment.trigger_type || 'branch',
40
+ triggerRef: deployment.trigger_ref || branch,
41
+ connectionId,
42
+ ...workflowConfig,
43
+ });
44
+ const workflowTarget = resolveProjectFileTarget(workspace, workflowPath);
45
+ if (workflowTarget.blockers.length) {
46
+ throw commandError('github_workflow_path_invalid', `workflow 경로가 파일에 막혀 있습니다: ${workflowPath}`);
47
+ }
48
+ const target = workflowTarget.target;
49
+ if (fs.existsSync(target)) {
50
+ const existing = fs.readFileSync(target, 'utf8');
51
+ const connectionMarker = `JORIPSPACE_CONNECTION_ID: ${JSON.stringify(connectionId)}`;
52
+ if (!existing.startsWith('# joripspace-workflow-version: ') || !existing.includes(connectionMarker)) {
53
+ throw commandError('github_workflow_conflict', `기존 workflow를 덮어쓰지 않았습니다: ${workflowPath}`);
54
+ }
55
+ }
56
+ writeTextAtomically(target, workflow);
57
+ output(flags, {
58
+ status: 'prepared',
59
+ project: details.project_slug || details.project_id || project,
60
+ repository,
61
+ branch,
62
+ workflow_path: workflowPath,
63
+ entrypoint: workflowConfig.entrypoint,
64
+ }, (value) => {
65
+ console.log(`GitHub workflow prepared: ${value.workflow_path}`);
66
+ console.log(`Repository: ${value.repository}`);
67
+ console.log(`Branch: ${value.branch}`);
68
+ console.log(`Entrypoint: ${value.entrypoint}`);
69
+ });
70
+ };
71
+ }
72
+
73
+ function inferWorkflowConfig(workspace, flags, stringFlag) {
74
+ const packageJson = readJson(path.join(workspace, 'package.json'));
75
+ const deployConfig = readJson(path.join(workspace, '.joripspace', 'deploy.json'));
76
+ const wranglerToml = readText(path.join(workspace, 'wrangler.toml'));
77
+ const wranglerJson = readText(
78
+ fs.existsSync(path.join(workspace, 'wrangler.jsonc'))
79
+ ? path.join(workspace, 'wrangler.jsonc')
80
+ : path.join(workspace, 'wrangler.json')
81
+ );
82
+ const explicitEntrypoint = stringFlag(flags, 'entrypoint');
83
+ const configuredEntrypoint =
84
+ explicitEntrypoint ||
85
+ (typeof deployConfig.entrypoint === 'string' ? deployConfig.entrypoint : '') ||
86
+ wranglerToml.match(/^\s*main\s*=\s*["']([^"']+)["']/mu)?.[1] ||
87
+ wranglerJson.match(/["']main["']\s*:\s*["']([^"']+)["']/u)?.[1] ||
88
+ (typeof packageJson.main === 'string' ? packageJson.main : '');
89
+ const candidates = [
90
+ configuredEntrypoint,
91
+ 'worker.js',
92
+ 'src/index.js',
93
+ 'src/index.ts',
94
+ 'src/worker.js',
95
+ 'src/worker.ts',
96
+ 'server.js',
97
+ ].filter(Boolean);
98
+ let entrypoint = '';
99
+ for (const candidate of candidates) {
100
+ const normalized = String(candidate).replace(/^\.\//u, '').replace(/\\/g, '/');
101
+ let location;
102
+ try {
103
+ location = resolveProjectFileTarget(workspace, normalized);
104
+ } catch (error) {
105
+ if (candidate === configuredEntrypoint) throw error;
106
+ continue;
107
+ }
108
+ if (location.blockers.length === 0 && fs.existsSync(location.target)) {
109
+ entrypoint = location.relative;
110
+ break;
111
+ }
112
+ }
113
+ if (!entrypoint) {
114
+ throw commandError(
115
+ 'github_entrypoint_not_detected',
116
+ 'Worker 시작 파일을 찾지 못했습니다. 소스를 작성하거나 --entrypoint를 지정한 뒤 다시 실행해 주세요.'
117
+ );
118
+ }
119
+ const scripts = packageJson.scripts && typeof packageJson.scripts === 'object' ? packageJson.scripts : {};
120
+ const buildCommand = [
121
+ ...(typeof scripts.build === 'string'
122
+ ? ['if [ -f package-lock.json ]; then npm ci; else npm install; fi', 'npm run build']
123
+ : []),
124
+ 'rm -rf .joripspace-artifact',
125
+ 'mkdir -p .joripspace-artifact',
126
+ "while IFS= read -r -d '' file; do",
127
+ ' if [ -f .joripspaceignore ] && git -c core.excludesFile="$PWD/.joripspaceignore" check-ignore --no-index -q -- "$file"; then',
128
+ ' continue',
129
+ ' fi',
130
+ ' target=".joripspace-artifact/${file#./}"',
131
+ ' mkdir -p "$(dirname "$target")"',
132
+ ' cp "$file" "$target"',
133
+ "done < <(find . \\\n \\( -path './.git' -o -path './node_modules' -o -path './.wrangler' -o -path './.cache' -o -path './coverage' -o -path './.github' -o -path './.joripspace' -o -path './.joripspace-artifact' -o -path '*/test' -o -path '*/tests' -o -path '*/__tests__' -o -path './docs' \\) -prune -o \\\n -type f ! -name '.env' ! -name '.env.*' ! -name '.dev.vars' ! -name '*.pem' ! -name '*.key' ! -name '*.test.*' ! -name '*.spec.*' ! -name 'AGENTS.md' ! -name 'CLAUDE.md' ! -name 'README*' ! -name 'LICENSE*' ! -name 'package.json' ! -name 'package-lock.json' ! -name 'npm-shrinkwrap.json' ! -name 'wrangler.toml' ! -name 'wrangler.json' ! -name 'wrangler.jsonc' ! -name 'tsconfig*.json' ! -name '.joripspaceignore' ! -name 'joripspace-template.json' -print0)",
134
+ ].join('\n');
135
+ return { entrypoint, artifactPath: '.joripspace-artifact', buildCommand };
136
+ }
137
+
138
+ function assertMatchingGitWorkspace(workspace, repository, branch) {
139
+ const inside = git(workspace, ['rev-parse', '--is-inside-work-tree']);
140
+ if (inside.status !== 0 || inside.stdout.trim() !== 'true') {
141
+ throw commandError('github_workspace_required', '먼저 joripspace start를 실행해 연결된 GitHub 작업 폴더를 준비해 주세요.');
142
+ }
143
+ const remote = git(workspace, ['remote', 'get-url', 'origin']);
144
+ if (remote.status !== 0 || githubRepository(remote.stdout.trim()) !== repository.toLowerCase()) {
145
+ throw commandError('github_repository_mismatch', '현재 작업 폴더의 origin이 연결된 GitHub 저장소와 다릅니다.');
146
+ }
147
+ const currentBranch = git(workspace, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
148
+ if (currentBranch.status !== 0 || currentBranch.stdout.trim() !== branch) {
149
+ throw commandError('github_branch_mismatch', `현재 작업 브랜치가 연결된 ${branch} 브랜치와 다릅니다.`);
150
+ }
151
+ }
152
+
153
+ function git(workspace, args) {
154
+ return spawnSync('git', ['-C', workspace, ...args], { encoding: 'utf8', windowsHide: true });
155
+ }
156
+
157
+ function githubRepository(remote) {
158
+ const value = String(remote || '').trim().replace(/\.git$/iu, '');
159
+ const match = /^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^/]+\/[^/]+)$/iu.exec(value);
160
+ return match ? match[1].toLowerCase() : '';
161
+ }
162
+
163
+ function validGitBranch(value) {
164
+ return Boolean(value) && value !== '@' && !value.startsWith('-') && !/[\x00-\x20\x7f~^:?*\\]/u.test(value) && !value.includes('..') && !value.includes('@{');
165
+ }
166
+
167
+ function readJson(filePath) {
168
+ const source = readText(filePath);
169
+ if (!source) return {};
170
+ try {
171
+ return JSON.parse(source);
172
+ } catch {
173
+ return {};
174
+ }
175
+ }
176
+
177
+ function readText(filePath) {
178
+ return fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';
179
+ }
180
+
181
+ function commandError(code, message) {
182
+ return Object.assign(new Error(message), { code });
183
+ }
184
+
185
+ module.exports = { createGithubCommands, inferWorkflowConfig };
package/lib/help.js CHANGED
@@ -1,16 +1,17 @@
1
- const DEFAULT_API_URL = 'https://api.joripspace.com';
2
-
3
- function printHelp() {
4
- console.log(`JoripSpace CLI
5
-
6
- Usage:
7
- joripspace login
8
- joripspace login --code "복사한_연결_코드" --cwd PROJECT_FOLDER
9
- joripspace login --connect-token "복사한_연결_토큰" --cwd PROJECT_FOLDER
10
- joripspace me
11
- joripspace projects
12
- joripspace link --project PROJECT --cwd PATH
13
- joripspace start PROJECT --cwd PATH --json
1
+ const DEFAULT_API_URL = 'https://api.joripspace.com';
2
+
3
+ function printHelp() {
4
+ console.log(`JoripSpace CLI
5
+
6
+ Usage:
7
+ joripspace login
8
+ joripspace login --code "복사한_연결_코드" --cwd PROJECT_FOLDER
9
+ joripspace login --connect-token "복사한_연결_토큰" --cwd PROJECT_FOLDER
10
+ joripspace me
11
+ joripspace projects
12
+ joripspace link --project PROJECT --cwd PATH
13
+ joripspace start PROJECT --cwd PATH --json
14
+ joripspace github prepare --project PROJECT --cwd PATH [--entrypoint worker.js]
14
15
  joripspace knowledge search --query "사용자 요청"
15
16
  joripspace realtime-v2 docs
16
17
  joripspace realtime-v2 status --project PROJECT
@@ -18,129 +19,129 @@ Usage:
18
19
  joripspace realtime-v2 rotate --project PROJECT
19
20
  joripspace realtime-v2 keys --project PROJECT --cursor CURSOR
20
21
  joripspace realtime-v2 revoke-key --project PROJECT --kid KEY_ID
21
- joripspace db schema --project PROJECT --token TOKEN
22
- joripspace db query --project PROJECT --token TOKEN --sql "SELECT name FROM sqlite_schema WHERE type = 'table'"
23
- joripspace db migrate --project PROJECT --token TOKEN --file migrations/001_init.sql
24
- joripspace storage list --project PROJECT --token TOKEN --prefix uploads/
25
- joripspace storage put --project PROJECT --token TOKEN --key uploads/hello.txt --text "hello"
26
- joripspace storage get --project PROJECT --token TOKEN --key uploads/hello.txt --out hello.txt
27
- joripspace storage delete --project PROJECT --token TOKEN --key uploads/hello.txt
28
- joripspace deploy --project PROJECT --token TOKEN --source worker.js --label "첫 배포"
29
- joripspace templates
30
- joripspace template list --project PROJECT --cursor CURSOR
31
- joripspace deploy-template --project PROJECT --token TOKEN --template basic-worker --label "기본 템플릿 배포" --var MESSAGE=Hello
32
- joripspace install-template --project PROJECT --token TOKEN --template TEMPLATE --dir . --deploy
33
- joripspace install-template --project PROJECT --token TOKEN --template TEMPLATE --dir . --files-only
34
- joripspace template pull --project PROJECT --token TOKEN --dir . [--yes]
35
- joripspace get --project PROJECT --token TOKEN
22
+ joripspace db schema --project PROJECT --token TOKEN
23
+ joripspace db query --project PROJECT --token TOKEN --sql "SELECT name FROM sqlite_schema WHERE type = 'table'"
24
+ joripspace db migrate --project PROJECT --token TOKEN --file migrations/001_init.sql
25
+ joripspace storage list --project PROJECT --token TOKEN --prefix uploads/
26
+ joripspace storage put --project PROJECT --token TOKEN --key uploads/hello.txt --text "hello"
27
+ joripspace storage get --project PROJECT --token TOKEN --key uploads/hello.txt --out hello.txt
28
+ joripspace storage delete --project PROJECT --token TOKEN --key uploads/hello.txt
29
+ joripspace deploy --project PROJECT --token TOKEN --source worker.js --label "첫 배포"
30
+ joripspace templates
31
+ joripspace template list --project PROJECT --cursor CURSOR
32
+ joripspace deploy-template --project PROJECT --token TOKEN --template basic-worker --label "기본 템플릿 배포" --var MESSAGE=Hello
33
+ joripspace install-template --project PROJECT --token TOKEN --template TEMPLATE --dir . --deploy
34
+ joripspace install-template --project PROJECT --token TOKEN --template TEMPLATE --dir . --files-only
35
+ joripspace template pull --project PROJECT --token TOKEN --dir . [--yes]
36
+ joripspace get --project PROJECT --token TOKEN
36
37
  joripspace deployments --project PROJECT --token TOKEN [--include-failure-details] [--json]
37
38
  joripspace deployment get --project PROJECT --deployment DEPLOYMENT_ID --json
38
- joripspace deployment pull --project PROJECT --deployment DEPLOYMENT_ID --cwd PATH [--force]
39
- joripspace checkpoint save --project PROJECT --token TOKEN --label "작업 완료"
40
- joripspace checkpoint list --project PROJECT --token TOKEN --limit 20
41
- joripspace checkpoint get --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID
42
- joripspace checkpoint update --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID --label "이름"
43
- joripspace checkpoint restore --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID
44
- joripspace checkpoint deploy --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID
45
- joripspace checkpoint delete --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID --yes
46
- joripspace rollback --project PROJECT --token TOKEN --deployment DEPLOYMENT_ID
47
- joripspace secrets --project PROJECT
48
- joripspace secret list --project PROJECT
49
- joripspace secret generate --project PROJECT --name SESSION_SECRET
50
- joripspace crons --project PROJECT
51
- joripspace cron create --project PROJECT --schedule "0 * * * *" --path /jobs/hourly
52
- joripspace cron run --project PROJECT --cron-id CRON_ID
53
- joripspace cron delete --project PROJECT --cron-id CRON_ID --yes
54
- joripspace domains --project PROJECT --token TOKEN
55
- joripspace domain create --project PROJECT --token TOKEN --hostname www.example.com
56
- joripspace domain verify --project PROJECT --token TOKEN --hostname www.example.com
57
- joripspace domain delete --project PROJECT --token TOKEN --hostname www.example.com --yes
58
- joripspace mail connect --project PROJECT
59
- joripspace mail status --project PROJECT
60
- joripspace mail test --project PROJECT [--to ADDRESS] [--subject TEXT]
61
- joripspace events --project PROJECT --token TOKEN --event-type error
62
- joripspace usage-summary --project PROJECT --from 2026-06-01 --to 2026-06-30
63
- joripspace usage-breakdown --project PROJECT --from 2026-06-01 --to 2026-06-30 --group-by day
64
- joripspace usage-breakdown --project PROJECT --from 2026-06-01 --to 2026-06-30 --group-by month
65
-
66
- Environment:
67
- JORIPSPACE_API_URL Defaults to ${DEFAULT_API_URL}
68
- JORIPSPACE_ACCOUNT_ID Used when --account is omitted
69
- JORIPSPACE_API_TOKEN Used when --token is omitted
70
- JORIPSPACE_CONNECT_TOKEN Used when no API token is provided
71
-
72
- Login:
73
- Run "joripspace login", open the shown link in a logged-in browser, approve connection,
74
- then exchange the displayed 5-minute connection code with --code.
75
- Existing connection tokens can still be saved with --connect-token.
76
- If a token is missing, do not inspect cookies, browser storage, or profile pages to find it.
77
- Open https://joripspace.com/connect/ and ask the user to paste the displayed connection code.
78
- The token and matching API URL are stored only in PROJECT_FOLDER/.env.joripspace. The CLI searches
79
- parent folders for this file. It never reads a generic application .env file for authentication.
80
-
81
- Security:
82
- CLI tokens are for project lookup, workspace linking, project DB/storage work, server deployment, usage, and logs.
83
- Project checkpoints can be saved, restored locally, and deployed independently with the checkpoint command.
84
- Deployment rollback, value-blind Secret generation/listing, crons, domains, and mail status/test are available.
85
- Manage custom domains with the domain command.
86
- Manage members, billing, API tokens, external Secret values, webhooks, and project deletion in the web UI.
87
-
88
- Global flags:
89
- --api-url URL
90
- --cwd PATH
91
- --json
92
- --help
93
- `);
94
- }
95
-
96
- function printDeployHelp() {
97
- console.log(`JoripSpace deploy
98
-
99
- Usage:
100
- joripspace deploy --project PROJECT --token TOKEN --source worker.js --label "첫 배포"
101
-
102
- Options:
103
- --source PATH Deploy one source file. Entrypoint defaults to the file basename.
104
- --dir PATH Deploy every safe file under a directory. Authentication is resolved from --cwd.
105
- --file NAME=PATH Add one file mapping. Can be repeated.
106
- --entrypoint NAME Server module entrypoint.
107
- --label TEXT Required deployment label, up to 120 characters.
108
- `);
109
- }
110
-
111
- function printDeployTemplateHelp() {
112
- console.log(`JoripSpace deploy-template
113
-
114
- Usage:
115
- joripspace templates
116
- joripspace deploy-template --project PROJECT --token TOKEN --template basic-worker --label "메시지 변경" --var MESSAGE=Hello
117
-
118
- Options:
119
- --template ID Template id from the templates command.
120
- --var KEY=VALUE Template variable. Can be repeated.
121
- --label TEXT Required deployment label, up to 120 characters.
122
- `);
123
- }
124
-
125
- function printInstallTemplateHelp() {
126
- console.log(`JoripSpace install-template
127
-
128
- Usage:
129
- joripspace install-template --project PROJECT --token TOKEN --template TEMPLATE --dir . --deploy
130
-
131
- Options:
132
- --template SLUG Marketplace template slug.
133
- --dir PATH Install directory. Defaults to the current directory.
134
- --files-only Copy template files without connecting Git history or template pull.
135
- --force Allow overwriting files with the same path.
136
- --deploy Deploy after installing the files.
137
- --entrypoint PATH Override the manifest entrypoint for deployment.
138
- --label TEXT Deployment label. A default is used when omitted.
139
-
140
- Template updates:
141
- "joripspace template pull" checks availability without downloading. Add --yes only after reviewing
142
- and approving the update; the bundle is then fetched through the local JoripSpace upstream channel.
143
- `);
144
- }
145
-
146
- module.exports = { printHelp, printDeployHelp, printDeployTemplateHelp, printInstallTemplateHelp };
39
+ joripspace deployment pull --project PROJECT --deployment DEPLOYMENT_ID --cwd PATH [--force]
40
+ joripspace checkpoint save --project PROJECT --token TOKEN --label "작업 완료"
41
+ joripspace checkpoint list --project PROJECT --token TOKEN --limit 20
42
+ joripspace checkpoint get --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID
43
+ joripspace checkpoint update --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID --label "이름"
44
+ joripspace checkpoint restore --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID
45
+ joripspace checkpoint deploy --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID
46
+ joripspace checkpoint delete --project PROJECT --token TOKEN --checkpoint CHECKPOINT_ID --yes
47
+ joripspace rollback --project PROJECT --token TOKEN --deployment DEPLOYMENT_ID
48
+ joripspace secrets --project PROJECT
49
+ joripspace secret list --project PROJECT
50
+ joripspace secret generate --project PROJECT --name SESSION_SECRET
51
+ joripspace crons --project PROJECT
52
+ joripspace cron create --project PROJECT --schedule "0 * * * *" --path /jobs/hourly
53
+ joripspace cron run --project PROJECT --cron-id CRON_ID
54
+ joripspace cron delete --project PROJECT --cron-id CRON_ID --yes
55
+ joripspace domains --project PROJECT --token TOKEN
56
+ joripspace domain create --project PROJECT --token TOKEN --hostname www.example.com
57
+ joripspace domain verify --project PROJECT --token TOKEN --hostname www.example.com
58
+ joripspace domain delete --project PROJECT --token TOKEN --hostname www.example.com --yes
59
+ joripspace mail connect --project PROJECT
60
+ joripspace mail status --project PROJECT
61
+ joripspace mail test --project PROJECT [--to ADDRESS] [--subject TEXT]
62
+ joripspace events --project PROJECT --token TOKEN --event-type error
63
+ joripspace usage-summary --project PROJECT --from 2026-06-01 --to 2026-06-30
64
+ joripspace usage-breakdown --project PROJECT --from 2026-06-01 --to 2026-06-30 --group-by day
65
+ joripspace usage-breakdown --project PROJECT --from 2026-06-01 --to 2026-06-30 --group-by month
66
+
67
+ Environment:
68
+ JORIPSPACE_API_URL Defaults to ${DEFAULT_API_URL}
69
+ JORIPSPACE_ACCOUNT_ID Used when --account is omitted
70
+ JORIPSPACE_API_TOKEN Used when --token is omitted
71
+ JORIPSPACE_CONNECT_TOKEN Used when no API token is provided
72
+
73
+ Login:
74
+ Run "joripspace login", open the shown link in a logged-in browser, approve connection,
75
+ then exchange the displayed 5-minute connection code with --code.
76
+ Existing connection tokens can still be saved with --connect-token.
77
+ If a token is missing, do not inspect cookies, browser storage, or profile pages to find it.
78
+ Open https://joripspace.com/connect/ and ask the user to paste the displayed connection code.
79
+ The token and matching API URL are stored only in PROJECT_FOLDER/.env.joripspace. The CLI searches
80
+ parent folders for this file. It never reads a generic application .env file for authentication.
81
+
82
+ Security:
83
+ CLI tokens are for project lookup, workspace linking, project DB/storage work, server deployment, usage, and logs.
84
+ Project checkpoints can be saved, restored locally, and deployed independently with the checkpoint command.
85
+ Deployment rollback, value-blind Secret generation/listing, crons, domains, and mail status/test are available.
86
+ Manage custom domains with the domain command.
87
+ Manage members, billing, API tokens, external Secret values, webhooks, and project deletion in the web UI.
88
+
89
+ Global flags:
90
+ --api-url URL
91
+ --cwd PATH
92
+ --json
93
+ --help
94
+ `);
95
+ }
96
+
97
+ function printDeployHelp() {
98
+ console.log(`JoripSpace deploy
99
+
100
+ Usage:
101
+ joripspace deploy --project PROJECT --token TOKEN --source worker.js --label "첫 배포"
102
+
103
+ Options:
104
+ --source PATH Deploy one source file. Entrypoint defaults to the file basename.
105
+ --dir PATH Deploy every safe file under a directory. Authentication is resolved from --cwd.
106
+ --file NAME=PATH Add one file mapping. Can be repeated.
107
+ --entrypoint NAME Server module entrypoint.
108
+ --label TEXT Required deployment label, up to 120 characters.
109
+ `);
110
+ }
111
+
112
+ function printDeployTemplateHelp() {
113
+ console.log(`JoripSpace deploy-template
114
+
115
+ Usage:
116
+ joripspace templates
117
+ joripspace deploy-template --project PROJECT --token TOKEN --template basic-worker --label "메시지 변경" --var MESSAGE=Hello
118
+
119
+ Options:
120
+ --template ID Template id from the templates command.
121
+ --var KEY=VALUE Template variable. Can be repeated.
122
+ --label TEXT Required deployment label, up to 120 characters.
123
+ `);
124
+ }
125
+
126
+ function printInstallTemplateHelp() {
127
+ console.log(`JoripSpace install-template
128
+
129
+ Usage:
130
+ joripspace install-template --project PROJECT --token TOKEN --template TEMPLATE --dir . --deploy
131
+
132
+ Options:
133
+ --template SLUG Marketplace template slug.
134
+ --dir PATH Install directory. Defaults to the current directory.
135
+ --files-only Copy template files without connecting Git history or template pull.
136
+ --force Allow overwriting files with the same path.
137
+ --deploy Deploy after installing the files.
138
+ --entrypoint PATH Override the manifest entrypoint for deployment.
139
+ --label TEXT Deployment label. A default is used when omitted.
140
+
141
+ Template updates:
142
+ "joripspace template pull" checks availability without downloading. Add --yes only after reviewing
143
+ and approving the update; the bundle is then fetched through the local JoripSpace upstream channel.
144
+ `);
145
+ }
146
+
147
+ module.exports = { printHelp, printDeployHelp, printDeployTemplateHelp, printInstallTemplateHelp };
@@ -1,28 +1,28 @@
1
- const path = require('node:path');
2
-
3
- function installerFlags(args) {
4
- const values = Array.isArray(args) ? args : [];
5
- return {
6
- wantsHelp: values.includes('--help') || values.includes('-h'),
7
- wantsJson: values.includes('--json'),
8
- wantsQuiet: values.includes('--quiet') || values.includes('-quiet'),
9
- wantsVersion: values.includes('--version') || values.includes('-v'),
10
- };
11
- }
12
-
13
- function normalizeWindowsPathEntry(value, env = process.env) {
14
- const variables = new Map(
15
- Object.entries(env || {}).map(([name, nested]) => [name.toLowerCase(), String(nested || '')])
16
- );
17
- const expanded = String(value || '')
18
- .trim()
19
- .replace(/^"|"$/g, '')
20
- .replace(/%([^%]+)%/g, (match, name) => variables.get(String(name).toLowerCase()) || match);
21
- if (!expanded) return '';
22
- return path.win32
23
- .normalize(expanded)
24
- .replace(/[\\/]+$/u, '')
25
- .toLowerCase();
26
- }
27
-
28
- module.exports = { installerFlags, normalizeWindowsPathEntry };
1
+ const path = require('node:path');
2
+
3
+ function installerFlags(args) {
4
+ const values = Array.isArray(args) ? args : [];
5
+ return {
6
+ wantsHelp: values.includes('--help') || values.includes('-h'),
7
+ wantsJson: values.includes('--json'),
8
+ wantsQuiet: values.includes('--quiet') || values.includes('-quiet'),
9
+ wantsVersion: values.includes('--version') || values.includes('-v'),
10
+ };
11
+ }
12
+
13
+ function normalizeWindowsPathEntry(value, env = process.env) {
14
+ const variables = new Map(
15
+ Object.entries(env || {}).map(([name, nested]) => [name.toLowerCase(), String(nested || '')])
16
+ );
17
+ const expanded = String(value || '')
18
+ .trim()
19
+ .replace(/^"|"$/g, '')
20
+ .replace(/%([^%]+)%/g, (match, name) => variables.get(String(name).toLowerCase()) || match);
21
+ if (!expanded) return '';
22
+ return path.win32
23
+ .normalize(expanded)
24
+ .replace(/[\\/]+$/u, '')
25
+ .toLowerCase();
26
+ }
27
+
28
+ module.exports = { installerFlags, normalizeWindowsPathEntry };