@@ -7,9 +7,11 @@ import { put } from "httpie";
77import { get_docs , DocFiles } from "./fs" ;
88import { transform_cloudflare , transform_docs } from "./transform" ;
99
10+ const CF_ACC_ID = "32a8245cd45a24083dd0acae1d482048" ;
11+ const CF_NS_ID = "20394261e26444aaa7ad8292db818037" ;
12+
1013const API_ROOT = "https://api.cloudflare.com/client/v4/" ;
11- const KV_WRITE = ( acc_id : string , ns_id : string ) =>
12- `accounts/${ acc_id } /storage/kv/namespaces/${ ns_id } /bulk` ;
14+ const KV_WRITE = `accounts/${ CF_ACC_ID } /storage/kv/namespaces/${ CF_NS_ID } /bulk` ;
1315
1416async function get_repo (
1517 target_repo : string ,
@@ -53,16 +55,14 @@ async function get_repo(
5355async function run ( ) {
5456 const target_repo = core . getInput ( "repo" ) ;
5557 const target_branch = core . getInput ( "branch" ) ;
56- const cf_token = core . getInput ( "token" ) ;
58+ const CF_TOKEN = core . getInput ( "token" ) ;
5759 const docs_path = core . getInput ( "docs_path" ) ;
5860 const pkg_path = core . getInput ( "pkg_path" ) ;
5961
6062 if ( target_branch !== "main" && target_branch !== "master" ) {
6163 core . setFailed ( "Branch deploys are not yet supported." ) ;
6264 }
6365
64- // get repo
65-
6666 try {
6767 await get_repo ( target_repo , target_branch , docs_path , pkg_path ) ;
6868 } catch ( e ) {
@@ -72,7 +72,6 @@ async function run() {
7272 ) ;
7373 }
7474
75- // read docs in
7675 let docs : [ string , DocFiles ] [ ] | false ;
7776
7877 try {
@@ -90,8 +89,6 @@ async function run() {
9089 )
9190 ) ;
9291
93- console . log ( JSON . stringify ( transformed_docs , null , 2 ) ) ;
94-
9592 const ready_for_cf = transformed_docs
9693 . map ( ( d ) =>
9794 d . map ( ( { content, project, type } ) =>
@@ -103,48 +100,18 @@ async function run() {
103100
104101 console . log ( JSON . stringify ( ready_for_cf , null , 2 ) ) ;
105102
103+ // try {
106104 // const x = await put(`${API_ROOT}${KV_WRITE}`, {
107- // body: keys ,
105+ // body: ready_for_cf ,
108106 // headers: {
109- // Authorization: `Bearer ${cf_token }`,
107+ // Authorization: `Bearer ${CF_TOKEN }`,
110108 // },
111109 // });
112110 // console.log("put: ", x);
113- // console.log({
114- // type: `${release_keys.map((v) => `${v}: ${repo.repo}:api:${v}`)}`,
115- // repo: repo.repo,
116- // base,
117- // key: `${repo.repo}:api:${version}`,
118- // });
119111 // } catch (e) {
120112 // console.log("it didn't work", e.message);
121113 // throw e;
122114 // }
123-
124- // if (docs.length) {
125- // docs.forEach(([project, docs]) => {
126- // for (const type in docs) {
127- // const _docs = format_docs[type](docs[type]);
128- // }
129- // });
130- // const formatted_base_docs = base_docs.docs.map(([name, content]) =>
131- // format_api(name, content, "docs", name)
132- // );
133- // console.log(JSON.stringify(formatted_base_docs, null, 2));
134-
135- // transform to cf format (batch keys)
136-
137- // const docs = transform_cloudflare(formatted_base_docs, {
138- // project: target_repo,
139- // type: "docs",
140- // keyby: "slug",
141- // });
142-
143- // console.log("\n");
144- // console.log(docs);
145- // }
146-
147- // write to cloudflare
148115}
149116
150117run ( ) ;
0 commit comments