Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(specs): publish docs specs #2255

Merged
merged 2 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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