-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation is now in Github first
- Loading branch information
Showing
15 changed files
with
2,950 additions
and
1,385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ jobs: | |
needs: [lint] | ||
strategy: | ||
matrix: | ||
node: [14, 16, 18] | ||
node: [16, 18] | ||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
|
@@ -59,7 +59,7 @@ jobs: | |
needs: [lint] | ||
strategy: | ||
matrix: | ||
node: [14, 16, 18] | ||
node: [16, 18] | ||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
|
@@ -87,3 +87,34 @@ jobs: | |
echo ::endgroup:: | ||
fi | ||
done | ||
sync: | ||
name: 🍿 Sync Doc to Crystallize | ||
if: github.event_name == 'push' && github.ref_name == 'main' | ||
runs-on: ubuntu-latest | ||
needs: [lint, test, builds] | ||
steps: | ||
- name: 🛑 Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
|
||
- name: ⎔ Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: 📥 Download deps | ||
run: yarn install && yarn build | ||
|
||
- name: 🚀 Sync it! | ||
env: | ||
MARKDOWN_TO_CRYSTALLIZE_SHARED_KEY: ${{ secrets.MARKDOWN_TO_CRYSTALLIZE_SHARED_KEY }} | ||
run: | | ||
for COMPONENT in `ls components`; do | ||
if [ -d "components/${COMPONENT}" ]; then | ||
echo ::group::..:: ${COMPONENT} ::.. | ||
node apps/doc2crystallize/build/index.js components/${COMPONENT}/README.md | ||
echo ::endgroup:: | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export declare function isFileExists(path: string): boolean; | ||
export declare function loadFile(path: string): Promise<any>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import fs from 'fs'; | ||
export function isFileExists(path) { | ||
return fs.existsSync(path); | ||
} | ||
export function loadFile(path) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(path, 'utf8', (err, content) => { | ||
if (err) { | ||
reject(err); | ||
} | ||
else { | ||
try { | ||
resolve(content); | ||
} | ||
catch (err) { | ||
reject(err); | ||
} | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { isFileExists, loadFile } from './fs-utils.js'; | ||
import md5 from 'md5'; | ||
import fetch from 'node-fetch'; | ||
const bossmanEndpoint = 'https://bossman.crystallize.com/md2crystal'; | ||
async function main(markdownFilePath) { | ||
if (!isFileExists(markdownFilePath)) { | ||
console.error(`File ${markdownFilePath} does not exist`); | ||
process.exit(1); | ||
} | ||
const markdown = await loadFile(markdownFilePath); | ||
const now = Math.floor(Date.now() / 1000); | ||
const key = md5(`${now}-X-${process.env.MARKDOWN_TO_CRYSTALLIZE_SHARED_KEY}`); | ||
const response = await fetch(bossmanEndpoint, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'text/plain', | ||
'X-Secure-Value': now.toFixed(0), | ||
'X-Secure-Signature': key, | ||
}, | ||
body: markdown, | ||
}); | ||
const result = await response.json(); | ||
if (result.status === 'ok') { | ||
console.log(`Publish to Crystallize: https://app.crystallize.com/@${result.tenantIdentifier}/en/catalogue/${result.type}/${result.objectId}`); | ||
} | ||
else { | ||
console.error(`File was not correctly published to Crystallize`); | ||
} | ||
} | ||
main(process.argv[2]).catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"type": "module", | ||
"name": "@crystallize/doc2crystallize", | ||
"version": "0.0.1", | ||
"engines": { | ||
"node": ">=16.0" | ||
}, | ||
"scripts": { | ||
"start": "node -r dotenv/config build/index.js", | ||
"watch": "tsc -W", | ||
"build": "tsc" | ||
}, | ||
"private": true, | ||
"volta": { | ||
"node": "16.14.2", | ||
"yarn": "1.22.18" | ||
}, | ||
"dependencies": { | ||
"dotenv": "^16.0.1", | ||
"md5": "^2.3.0", | ||
"node-fetch": "^3.3.0", | ||
"path": "^0.12.7" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/node16": "^1", | ||
"@types/md5": "^2.3.2", | ||
"@types/node": "^18.0.6", | ||
"typescript": "^4.7.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import fs from 'fs'; | ||
|
||
export function isFileExists(path: string): boolean { | ||
return fs.existsSync(path); | ||
} | ||
|
||
export function loadFile(path: string): Promise<any> { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(path, 'utf8', (err, content) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
try { | ||
resolve(content); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { isFileExists, loadFile } from './fs-utils.js'; | ||
import md5 from 'md5'; | ||
import fetch from 'node-fetch'; | ||
|
||
const bossmanEndpoint = 'https://bossman.crystallize.com/md2crystal'; | ||
|
||
async function main(markdownFilePath: string) { | ||
if (!isFileExists(markdownFilePath)) { | ||
console.error(`File ${markdownFilePath} does not exist`); | ||
process.exit(1); | ||
} | ||
const markdown = await loadFile(markdownFilePath); | ||
const now = Math.floor(Date.now() / 1000); | ||
const key = md5(`${now}-X-${process.env.MARKDOWN_TO_CRYSTALLIZE_SHARED_KEY}`); | ||
const response = await fetch(bossmanEndpoint, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'text/plain', | ||
'X-Secure-Value': now.toFixed(0), | ||
'X-Secure-Signature': key, | ||
}, | ||
body: markdown, | ||
}); | ||
const result: any = await response.json(); | ||
if (result.status === 'ok') { | ||
console.log( | ||
`Publish to Crystallize: https://app.crystallize.com/@${result.tenantIdentifier}/en/catalogue/${result.type}/${result.objectId}`, | ||
); | ||
} else { | ||
console.error(`File was not correctly published to Crystallize`); | ||
} | ||
} | ||
main(process.argv[2]).catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "@tsconfig/node16/tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./build", | ||
"declaration": true, | ||
"module": "ES2020", | ||
"moduleResolution": "node" | ||
}, | ||
"include": ["src/**/*.ts", "src/**/*.tsx"] | ||
} |
Oops, something went wrong.