@unana_dev/doxen 0.2.0 → 0.2.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Doxen
2
2
 
3
- > 기존 저장소의 Markdown 폴더를 설정 파일 하나로 연결하는 npm 패키지입니다. Node.js 22 이상이 필요합니다. 현재 0.2.0 구현 기준입니다.
3
+ > 기존 저장소의 Markdown 폴더를 설정 파일 하나로 연결하는 npm 패키지입니다. Node.js 22 이상이 필요합니다. 현재 0.2.1 구현 기준입니다.
4
4
 
5
5
  상단 탭, 폴더별 문서 탐색, 목차, 한국어 전체 검색, 검색 위치 이동, 문서 및 지정 섹션 안에서 찾기 기능을 제공합니다. React/Vue 등 사용자 프로젝트의 프레임워크에 의존하지 않으며, 사이트 소스는 패키지 안에 있습니다.
6
6
 
@@ -148,7 +148,15 @@ Markdown 수정 후 **같은 `npx doxen deploy` 명령**을 실행하세요. 설
148
148
 
149
149
  배포 이력·롤백·도메인은 Cloudflare Pages, 로그인·접근 정책은 Cloudflare One의 Access에서 관리합니다. 자동 설정은 기본 Pages 운영 주소와 미리보기 주소를 대상으로 합니다. 커스텀 도메인은 별도로 연결하고 Access로 보호해야 합니다.
150
150
 
151
- 새 열람자는 **운영·미리보기 Access 정책과 `.doxen-deploy.json`의 `emails`에 모두 추가**한 뒤 재배포합니다. 도구는 재배포 때 정책을 임의로 덮어쓰지 않고 목록의 일치를 검사합니다. 퇴사자 등의 접근을 회수할 때는 모든 관련 Access 정책에서 제거하고 활성 세션을 취소한 다음 저장된 목록도 수정해 재배포하세요. 이전 배포에는 당시 목록이 남으므로 필요하면 이전 배포도 삭제합니다. 롤백하면 이전 목록도 돌아올 수 있습니다.
151
+ 열람자를 변경하려면 **`.doxen-deploy.json`의 `emails`만 수정하고 `npx doxen deploy`를 실행**하세요. 기존 이메일을 유지하면서 새 주소를 추가하면 운영·미리보기의 Doxen 허용 정책에 자동 반영됩니다. 삭제한 주소도 두 정책에서 제거합니다. JSON 목록이 기준이므로 Cloudflare에서만 추가한 주소는 다음 동기화 때 제거됩니다.
152
+
153
+ ```json
154
+ "emails": ["member@company.com", "new-member@company.com"]
155
+ ```
156
+
157
+ 두 애플리케이션을 검사한 뒤 단일 `Doxen 열람자` 이메일 Allow 정책만 갱신하고 다시 조회하여 확인합니다. 별도 정책·그룹·추가 보안 조건이 있으면 덮어쓰지 않고 중단합니다. 중간 실패 시 문서는 업로드하지 않으며 같은 명령으로 다시 시도하면 남은 정책을 갱신합니다. 이미 반영된 정책 변경은 되돌리지 않습니다.
158
+
159
+ 이메일 제거가 기존 로그인 세션을 즉시 취소하지는 않습니다. 즉시 접근을 회수하려면 Cloudflare에서 활성 세션도 취소하세요. 커스텀 도메인의 별도 정책은 직접 관리해야 합니다. 이전 배포에는 당시 목록이 남으므로 필요하면 이전 배포도 삭제합니다. 롤백하면 이전 목록도 돌아올 수 있습니다.
152
160
 
153
161
  허용 사용자는 사이트 전체를 읽습니다. 문서별·탭별 권한은 제공하지 않습니다. 자동 설정은 초기 연결 과정을 줄이는 기능이며, 별도의 열람자 관리 화면은 아직 없습니다.
154
162
 
package/bin/docs.js CHANGED
@@ -19,7 +19,7 @@ try {
19
19
  },
20
20
  });
21
21
  const [command, ...extra] = positionals;
22
- if (values.version) console.log("0.2.0");
22
+ if (values.version) console.log("0.2.1");
23
23
  else if (values.help || !command)
24
24
  console.log(
25
25
  `Doxen — 저장소 기반 문서 사이트\n\n docs init 설정과 스크립트 생성\n docs dev [--port 4173] 로컬 미리보기 및 자동 갱신\n docs build .docs-dist 정적 사이트 생성\n docs deploy 최초 설정 안내 및 비공개 Cloudflare Pages 배포\n docs ai --file <문서.md> --instruction "변경 요청"\n 표준 양식과 AI 작업 지침을 stdout으로 출력\n\n옵션: --config <파일> (dev/build/deploy/ai), --help, --version\n동일 명령: doxen <명령>`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unana_dev/doxen",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Config-first Markdown documentation sites with Korean and section search",
5
5
  "type": "module",
6
6
  "bin": {
@@ -7,7 +7,7 @@ const tokenUrl = "https://dash.cloudflare.com/profile/api-tokens";
7
7
  const accountPattern = /^[a-f0-9]{32}$/i;
8
8
  const projectPattern = /^[a-z0-9][a-z0-9-]{0,57}[a-z0-9]$/;
9
9
  export const parseEmails = (text) => [...new Set(text.split(/[\s,;]+/).filter(Boolean).map((email) => email.toLowerCase()))];
10
- const validEmails = (emails) => emails.length > 0 && emails.every((email) => /^[^\s@*]+@[^\s@*]+\.[^\s@*]+$/.test(email));
10
+ const validEmails = (emails) => emails.length > 0 && emails.every((email) => typeof email === "string" && /^[^\s@*]+@[^\s@*]+\.[^\s@*]+$/.test(email));
11
11
 
12
12
  export async function terminalPrompts() {
13
13
  if (!process.stdin.isTTY || !process.stdout.isTTY)
@@ -71,13 +71,17 @@ export async function provision(config, state, api, log = console.log) {
71
71
  state.apps[kind] = { id: app.id, aud: app.aud };
72
72
  await persist();
73
73
  }
74
- await verifySetup(state, api);
74
+ await verifySetup(state, api, { syncEmails: true, log });
75
75
  state.ready = true;
76
76
  await persist();
77
77
  return validateDeployment(deploymentFromState(state));
78
78
  }
79
79
 
80
- export async function verifySetup(state, api) {
80
+ export async function verifySetup(state, api, { syncEmails = false, log = console.log } = {}) {
81
+ if (!Array.isArray(state.emails) || !validEmails(state.emails))
82
+ throw new Error("emails에 허용할 이메일을 하나 이상 입력하세요.");
83
+ const desired = [...new Set(state.emails.map((email) => email.toLowerCase()))];
84
+ const updates = [];
81
85
  const base = `/accounts/${state.accountId}`;
82
86
  for (const [kind, domain] of [["production", state.hostname], ["preview", `*.${state.hostname}`]]) {
83
87
  const saved = state.apps[kind];
@@ -92,10 +96,34 @@ export async function verifySetup(state, api) {
92
96
  const policy = policies[0];
93
97
  const actual = policy?.include?.map((rule) => Object.keys(rule).length === 1 ? rule.email?.email?.toLowerCase() : undefined);
94
98
  if (policies.length !== 1 || policy.decision !== "allow" || !actual ||
95
- actual.length !== state.emails.length || actual.some((email) => !state.emails.includes(email)) ||
96
- new Set(actual).size !== state.emails.length)
97
- throw new Error("허용 이메일 정책이 변경되었거나 확인되지 않았습니다. Cloudflare 정책과 .doxen-deploy.json의 emails를 일치시킨 뒤 다시 실행하세요.");
99
+ !validEmails(actual))
100
+ throw new Error("허용 이메일 정책이 변경되었거나 확인되지 않았습니다. Doxen의 단일 이메일 Allow 정책만 자동 관리합니다.");
101
+ const same = actual.length === desired.length && new Set(actual).size === desired.length &&
102
+ actual.every((email) => desired.includes(email));
103
+ if (same) continue;
104
+ if (!syncEmails)
105
+ throw new Error("허용 이메일 정책이 아직 로컬 emails와 일치하지 않습니다. 같은 배포 명령으로 다시 시도하세요.");
106
+ // Do not replace reusable policies or discard manually added security conditions.
107
+ if (policy.name !== "Doxen 열람자" || !/^[\da-f-]{36}$/i.test(policy.id) ||
108
+ policy.reusable === true || policy.app_count > 1 || policy.require?.length ||
109
+ policy.exclude?.length || policy.approval_required || policy.approval_groups?.length ||
110
+ policy.purpose_justification_required || policy.connection_rules)
111
+ throw new Error("허용 이메일 정책에 별도 조건이 설정되어 자동 수정할 수 없습니다. 기존 보안 설정을 확인하세요.");
112
+ const body = {
113
+ name: policy.name, decision: "allow",
114
+ include: desired.map((email) => ({ email: { email } })),
115
+ };
116
+ for (const key of ["precedence", "session_duration", "isolation_required", "mfa_config"])
117
+ if (policy[key] !== undefined) body[key] = policy[key];
118
+ updates.push({ route: `${route}/policies/${policy.id}`, body });
98
119
  }
120
+ // Validate both applications before changing either. Retrying repairs a partial update.
121
+ for (const update of updates) {
122
+ log("JSON의 허용 이메일 목록을 Cloudflare 정책에 반영합니다.");
123
+ await api.send(update.route, "PUT", update.body);
124
+ }
125
+ if (updates.length) await verifySetup(state, api);
126
+
99
127
  }
100
128
 
101
129
  export async function prepareDeployment(config, {
@@ -141,7 +169,7 @@ export async function prepareDeployment(config, {
141
169
  const credentials = { ...env, CLOUDFLARE_ACCOUNT_ID: account, CLOUDFLARE_API_TOKEN: token };
142
170
  if (config.deploy && !state) return { config, env: credentials };
143
171
  if (state?.ready) {
144
- await verifySetup(state, api);
172
+ await verifySetup(state, api, { syncEmails: true, log });
145
173
  return { config: { ...config, deploy: validateDeployment(deploymentFromState(state)) }, env: credentials };
146
174
  }
147
175
  const ask = await ui();