Skip to content

Commit

Permalink
chore(specs): publish docs specs (#2255)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Nov 13, 2023
1 parent 03136e0 commit 5a7a8ae
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 20 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
"scripts:test": "yarn workspace scripts test",
"specs:fix": "eslint --ext=yml specs/$0 --fix",
"specs:lint": "eslint --ext=yml specs/$0",
"website": "yarn website:build-specs && cd website && yarn start",
"website:build": "bash scripts/website/build.sh",
"website:build-specs": "BUNDLE_WITH_DOC=true DOCKER=true yarn cli build specs all -s"
"website": "DOCKER=true yarn cli build specs all -s && cd website && yarn start",
"website:build": "bash scripts/website/build.sh"
},
"devDependencies": {
"@babel/eslint-parser": "7.22.15",
Expand Down
17 changes: 4 additions & 13 deletions scripts/buildSpecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fsp from 'fs/promises';

import yaml from 'js-yaml';

import { BUNDLE_WITH_DOC, checkForCache, exists, run, toAbsolutePath } from './common.js';
import { checkForCache, exists, run, toAbsolutePath } from './common.js';
import { createSpinner } from './spinners.js';
import type { Spec } from './types.js';

Expand Down Expand Up @@ -87,18 +87,9 @@ async function transformBundle({
);

if (withDoc) {
const docFolderPath = toAbsolutePath('website/specs');
if (!(await exists(docFolderPath))) {
fsp.mkdir(docFolderPath, { recursive: true });
}
const pathToDocFile = toAbsolutePath(`specs/bundled/${clientName}.doc.yml`);

const pathToSpecDoc = `${docFolderPath}/${clientName}.doc.yml`;
await fsp.writeFile(
pathToSpecDoc,
yaml.dump(bundledDocSpec, {
noRefs: true,
})
);
await fsp.writeFile(pathToDocFile, yaml.dump(bundledDocSpec, { noRefs: true }));
}
}

Expand Down Expand Up @@ -219,7 +210,7 @@ async function buildSpec(spec: string, outputFormat: string, useCache: boolean):
await transformBundle({
bundledPath: toAbsolutePath(bundledPath),
clientName: spec,
withDoc: BUNDLE_WITH_DOC,
withDoc: true,
});
} else {
await buildLiteSpec({
Expand Down
1 change: 0 additions & 1 deletion scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const TODAY = new Date().toISOString().split('T')[0];

export const CI = Boolean(process.env.CI);
export const DOCKER = Boolean(process.env.DOCKER);
export const BUNDLE_WITH_DOC = process.env.BUNDLE_WITH_DOC === 'true';

// This script is run by `yarn workspace ...`, which means the current working directory is `./script`
const ROOT_DIR = path.resolve(process.cwd(), '..');
Expand Down
3 changes: 1 addition & 2 deletions scripts/website/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# treat website as independant yarn project
touch website/yarn.lock

# build doc specs
yarn website:build-specs
DOCKER=true yarn cli build specs all -s

# install website deps and build
cd website && yarn install && yarn build
2 changes: 1 addition & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require('fs');
const path = require('path');

function getSpecFiles() {
const bundledSpecsPath = path.resolve(process.cwd(), 'specs');
const bundledSpecsPath = path.resolve(process.cwd(), '../specs/bundled');
const specs = [];

fs.readdirSync(bundledSpecsPath).forEach((file) => {
Expand Down

0 comments on commit 5a7a8ae

Please sign in to comment.