Socket
Socket
Sign inDemoInstall

@wixc3/docs

Package Overview
Dependencies
Maintainers
84
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wixc3/docs - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

dist/cjs/build-docs/build-docs.d.ts

6

dist/cjs/cli.d.ts

@@ -1,8 +0,2 @@

export declare const siteUrl: {
alias: string;
default: string;
describe: string;
string: boolean;
};
export declare function cli(): void;
//# sourceMappingURL=cli.d.ts.map

67

dist/cjs/cli.js

@@ -6,55 +6,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.cli = exports.siteUrl = void 0;
exports.cli = void 0;
const path_1 = require("path");
const yargs_1 = __importDefault(require("yargs/yargs"));
const build_docs_1 = require("./build-docs");
const build_docs_1 = require("./build-docs/build-docs");
const common_1 = require("./common");
const create_readme_1 = require("./create-readme");
const init_1 = require("./init");
const packages = {
alias: 'p',
default: 'packages',
describe: 'workspaces (packages) directory',
string: true,
};
const skipAnalyze = {
alias: 'a',
default: false,
describe: 'Use cache analyzed api',
boolean: true,
};
const docs = {
alias: 'o',
default: '_docs',
describe: 'target directory',
string: true,
};
const conf = {
alias: 'c',
default: 'docs-conf',
describe: 'index/package/item headers and other configuration',
string: true,
};
const base = {
alias: 'b',
default: '.',
describe: 'project root',
string: true,
};
const temp = {
alias: 't',
default: 'temp',
describe: 'temp files directory',
boolean: true,
};
const force = {
alias: 'f',
default: false,
describe: 'overwrite existing configuration',
boolean: true,
};
exports.siteUrl = {
alias: 's',
default: 'https://<org>.github.io/<repo>',
describe: `base URL of the project's github pages`,
string: true,
};
const cli_options_1 = require("./cli.options");
function cli() {

@@ -64,10 +19,10 @@ (0, yargs_1.default)(process.argv.slice(2))

.usage('$0 <cmd> [args]')
.command('build', 'Build doc markdown from packages TSDocs', { conf, skipAnalyze }, ({ conf, skipAnalyze }) => {
(0, build_docs_1.buildDocs)(conf, skipAnalyze);
.command('build', 'Build doc markdown from packages TSDocs', { conf: cli_options_1.conf, base: cli_options_1.base, skipAnalyze: cli_options_1.skipAnalyze }, ({ base, conf, skipAnalyze }) => {
(0, build_docs_1.buildDocs)((0, common_1.loadConfig)((0, path_1.join)(base, conf)), { analyze: !skipAnalyze });
})
.command('init', 'initialize docs config and github pages action', { packages, conf, docs, siteUrl: exports.siteUrl, base, temp, force }, ({ packages, conf, docs, siteUrl, base, temp, force }) => {
(0, init_1.init)({ packages, conf, docs, siteUrl, base, temp }, force);
.command('init', 'initialize docs config and github pages action', { packages: cli_options_1.packages, conf: cli_options_1.conf, docs: cli_options_1.docs, siteUrl: cli_options_1.siteUrl, base: cli_options_1.base, temp: cli_options_1.temp, force: cli_options_1.force, origin: cli_options_1.origin }, ({ packages, conf, docs, siteUrl, base, temp, force, origin }) => {
(0, init_1.init)({ packages, conf, docs, siteUrl, base, temp, origin }, force);
})
.command(['readme'], 'create README.md for all the packages', { conf, siteUrl: exports.siteUrl }, ({ conf, siteUrl }) => {
(0, create_readme_1.createReadme)(conf, siteUrl);
.command('readme', 'create README.md for all the packages', { conf: cli_options_1.conf, base: cli_options_1.base, siteUrl: cli_options_1.siteUrl }, ({ conf, base, siteUrl }) => {
(0, create_readme_1.createReadme)((0, common_1.loadConfig)((0, path_1.join)(base, conf)), siteUrl);
})

@@ -74,0 +29,0 @@ .demandCommand()

import { Nullable } from '@wixc3/common';
import type { Macro } from './macros.types';
export declare function listPackages(config: UserConfig): {
export type Package = {
dir: string;
name: string;
unscopedName: string;
}[];
export declare const getPackageByUnscopedName: (config: Config, unscopedName: string) => {
dir: string;
name: string;
unscopedName: string;
};
export declare function listPackages(config: UserConfig): Package[];
export declare const getPackageByUnscopedName: (config: Config, unscopedName: string) => Package;
export declare const stripName: (name: string) => string;

@@ -21,3 +18,3 @@ export declare const unscopedPackageName: (name: string) => string;

export declare const execMacro: (data: string, replace: Record<string, string | ((...args: string[]) => string)>) => string;
export declare type Repo = {
export type Repo = {
host: string;

@@ -31,3 +28,3 @@ org: string;

export declare function getRepo(): Nullable<Repo>;
export declare type UserConfig = {
export type UserConfig = {
conf: string;

@@ -38,8 +35,9 @@ base: string;

docs: string;
origin?: string;
siteUrl?: string;
};
export declare type Config = UserConfig & {
export type Config = UserConfig & {
git: Repo;
};
export declare type ProcessingConfig = Config & {
export type ProcessingConfig = Config & {
modifier?: (name: string, content: string) => string;

@@ -46,0 +44,0 @@ macros: Record<string, Macro>;

@@ -110,5 +110,5 @@ "use strict";

function isWixDocs(config) {
return config.git.github === 'https://github.com/wixplosives/core3-utils';
return config.git.github === 'https://github.com/wixplosives/core3-utils' && config.base === '.';
}
exports.isWixDocs = isWixDocs;
//# sourceMappingURL=common.js.map

@@ -1,2 +0,3 @@

export declare function createReadme(conf: string, siteUrl: string): void;
import { Config } from './common';
export declare function createReadme(config: Config, siteUrl?: string): void;
//# sourceMappingURL=create-readme.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createReadme = void 0;
const path_1 = require("path");
const fs_utils_1 = require("@wixc3/fs-utils");
const common_1 = require("./common");
const fs_1 = require("fs");
const cli_1 = require("./cli");
function createReadme(conf, siteUrl) {
const config = (0, common_1.loadConfig)(conf);
if (siteUrl === cli_1.siteUrl.default) {
const cli_options_1 = require("./cli.options");
const prettier_1 = require("prettier");
function createReadme(config, siteUrl = cli_options_1.siteUrl.default) {
if (siteUrl === cli_options_1.siteUrl.default) {
siteUrl = config.git.pages;
}
siteUrl = (0, fs_utils_1.backSlash)(siteUrl, 'trailing');
const copyWithSiteUrlLinks = (filename, packageName, packagesPath) => {
let content = (0, fs_1.readFileSync)((0, path_1.join)(config.docs, `${filename}.md`), 'utf8');
const copyWithSiteUrlLinks = (pkg) => {
let content = (0, fs_1.readFileSync)((0, common_1._docs)(config, `${pkg.unscopedName}.md`), 'utf8');
for (const [all, caption, uri, ext] of content.matchAll(/\[(.*?)\]\(\.\/([^)]*)\.(.+?)\)/g)) {
content = content.replace(all, `[${caption}](${siteUrl}${uri}${ext === 'md' ? '' : ext})`);
content = content.replace(all || '', `[${caption}](${siteUrl}${uri}${ext === 'md' ? '' : ext})`);
}
(0, fs_1.writeFileSync)((0, path_1.join)(packagesPath, packageName, 'README.md'), content, 'utf8');
content = (0, prettier_1.format)(content, { parser: 'markdown' });
(0, fs_1.writeFileSync)((0, common_1._packages)(config, pkg.dir, 'README.md'), content, 'utf8');
};
(0, common_1.listPackages)(config).map(({ dir, unscopedName }) => copyWithSiteUrlLinks(dir, unscopedName, config.packages));
copyWithSiteUrlLinks('index', '.', '.');
(0, common_1.listPackages)(config).map(pkg => copyWithSiteUrlLinks(pkg));
copyWithSiteUrlLinks({ dir: '..', name: 'index', unscopedName: 'index' });
}
exports.createReadme = createReadme;
//# sourceMappingURL=create-readme.js.map

@@ -35,3 +35,3 @@ /**

*/
export * from './build-docs';
export * from './build-docs/build-docs';
export * from './create-readme';

@@ -38,0 +38,0 @@ export * from './init';

@@ -52,3 +52,3 @@ "use strict";

*/
__exportStar(require("./build-docs"), exports);
__exportStar(require("./build-docs/build-docs"), exports);
__exportStar(require("./create-readme"), exports);

@@ -55,0 +55,0 @@ __exportStar(require("./init"), exports);

@@ -12,3 +12,3 @@ import { UserConfig } from './common';

*/
export declare function init(config: UserConfig, force?: boolean, overrideOrigin?: string): void;
export declare function init(config: UserConfig, force?: boolean): void;
//# sourceMappingURL=init.d.ts.map

@@ -7,2 +7,3 @@ "use strict";

const fs_1 = require("fs");
const cli_options_1 = require("./cli.options");
/**

@@ -17,3 +18,3 @@ * Initialize docs pre-requisites:

*/
function init(config, force = false, overrideOrigin) {
function init(config, force = false) {
const relConfig = (0, path_1.relative)((0, common_1._packages)(config, 'pkg'), (0, common_1._config)(config));

@@ -40,3 +41,5 @@ const resources = (0, path_1.join)(__dirname, '..', '..', 'resources');

...config,
git: (0, common_1.getRepo)(true, overrideOrigin),
git: (0, common_1.getRepo)(true, config.origin === cli_options_1.origin.default
? undefined
: `origin ${config.origin} (fetch)\norigin ${config.origin} (push)`)
}, force);

@@ -43,0 +46,0 @@ template('api-extractor.base.json');

import { ProcessingConfig } from './common';
export { ProcessingConfig };
export declare type Macro = (config: ProcessingConfig, filename: string, ...args: string[]) => string;
export declare type Macros = Record<string, Macro>;
export type Macro = (config: ProcessingConfig, filename: string, ...args: string[]) => string;
export type Macros = Record<string, Macro>;
export declare class MacroError extends Error {

@@ -6,0 +6,0 @@ config: ProcessingConfig;

@@ -1,8 +0,2 @@

export declare const siteUrl: {
alias: string;
default: string;
describe: string;
string: boolean;
};
export declare function cli(): void;
//# sourceMappingURL=cli.d.ts.map

@@ -0,53 +1,8 @@

import { join } from 'path';
import yargs from 'yargs/yargs';
import { buildDocs } from './build-docs';
import { buildDocs } from './build-docs/build-docs';
import { loadConfig } from './common';
import { createReadme } from './create-readme';
import { init } from './init';
const packages = {
alias: 'p',
default: 'packages',
describe: 'workspaces (packages) directory',
string: true,
};
const skipAnalyze = {
alias: 'a',
default: false,
describe: 'Use cache analyzed api',
boolean: true,
};
const docs = {
alias: 'o',
default: '_docs',
describe: 'target directory',
string: true,
};
const conf = {
alias: 'c',
default: 'docs-conf',
describe: 'index/package/item headers and other configuration',
string: true,
};
const base = {
alias: 'b',
default: '.',
describe: 'project root',
string: true,
};
const temp = {
alias: 't',
default: 'temp',
describe: 'temp files directory',
boolean: true,
};
const force = {
alias: 'f',
default: false,
describe: 'overwrite existing configuration',
boolean: true,
};
export const siteUrl = {
alias: 's',
default: 'https://<org>.github.io/<repo>',
describe: `base URL of the project's github pages`,
string: true,
};
import { base, conf, docs, force, origin, packages, siteUrl, skipAnalyze, temp } from './cli.options';
export function cli() {

@@ -57,10 +12,10 @@ yargs(process.argv.slice(2))

.usage('$0 <cmd> [args]')
.command('build', 'Build doc markdown from packages TSDocs', { conf, skipAnalyze }, ({ conf, skipAnalyze }) => {
buildDocs(conf, skipAnalyze);
.command('build', 'Build doc markdown from packages TSDocs', { conf, base, skipAnalyze }, ({ base, conf, skipAnalyze }) => {
buildDocs(loadConfig(join(base, conf)), { analyze: !skipAnalyze });
})
.command('init', 'initialize docs config and github pages action', { packages, conf, docs, siteUrl, base, temp, force }, ({ packages, conf, docs, siteUrl, base, temp, force }) => {
init({ packages, conf, docs, siteUrl, base, temp }, force);
.command('init', 'initialize docs config and github pages action', { packages, conf, docs, siteUrl, base, temp, force, origin }, ({ packages, conf, docs, siteUrl, base, temp, force, origin }) => {
init({ packages, conf, docs, siteUrl, base, temp, origin }, force);
})
.command(['readme'], 'create README.md for all the packages', { conf, siteUrl }, ({ conf, siteUrl }) => {
createReadme(conf, siteUrl);
.command('readme', 'create README.md for all the packages', { conf, base, siteUrl }, ({ conf, base, siteUrl }) => {
createReadme(loadConfig(join(base, conf)), siteUrl);
})

@@ -67,0 +22,0 @@ .demandCommand()

import { Nullable } from '@wixc3/common';
import type { Macro } from './macros.types';
export declare function listPackages(config: UserConfig): {
export type Package = {
dir: string;
name: string;
unscopedName: string;
}[];
export declare const getPackageByUnscopedName: (config: Config, unscopedName: string) => {
dir: string;
name: string;
unscopedName: string;
};
export declare function listPackages(config: UserConfig): Package[];
export declare const getPackageByUnscopedName: (config: Config, unscopedName: string) => Package;
export declare const stripName: (name: string) => string;

@@ -21,3 +18,3 @@ export declare const unscopedPackageName: (name: string) => string;

export declare const execMacro: (data: string, replace: Record<string, string | ((...args: string[]) => string)>) => string;
export declare type Repo = {
export type Repo = {
host: string;

@@ -31,3 +28,3 @@ org: string;

export declare function getRepo(): Nullable<Repo>;
export declare type UserConfig = {
export type UserConfig = {
conf: string;

@@ -38,8 +35,9 @@ base: string;

docs: string;
origin?: string;
siteUrl?: string;
};
export declare type Config = UserConfig & {
export type Config = UserConfig & {
git: Repo;
};
export declare type ProcessingConfig = Config & {
export type ProcessingConfig = Config & {
modifier?: (name: string, content: string) => string;

@@ -46,0 +44,0 @@ macros: Record<string, Macro>;

@@ -91,4 +91,4 @@ import { first } from '@wixc3/common';

export function isWixDocs(config) {
return config.git.github === 'https://github.com/wixplosives/core3-utils';
return config.git.github === 'https://github.com/wixplosives/core3-utils' && config.base === '.';
}
//# sourceMappingURL=common.js.map

@@ -1,2 +0,3 @@

export declare function createReadme(conf: string, siteUrl: string): void;
import { Config } from './common';
export declare function createReadme(config: Config, siteUrl?: string): void;
//# sourceMappingURL=create-readme.d.ts.map

@@ -1,8 +0,7 @@

import { join } from 'path';
import { backSlash } from '@wixc3/fs-utils';
import { listPackages, loadConfig } from './common';
import { listPackages, _docs, _packages } from './common';
import { readFileSync, writeFileSync } from 'fs';
import { siteUrl as site } from './cli';
export function createReadme(conf, siteUrl) {
const config = loadConfig(conf);
import { siteUrl as site } from './cli.options';
import { format } from 'prettier';
export function createReadme(config, siteUrl = site.default) {
if (siteUrl === site.default) {

@@ -12,12 +11,13 @@ siteUrl = config.git.pages;

siteUrl = backSlash(siteUrl, 'trailing');
const copyWithSiteUrlLinks = (filename, packageName, packagesPath) => {
let content = readFileSync(join(config.docs, `${filename}.md`), 'utf8');
const copyWithSiteUrlLinks = (pkg) => {
let content = readFileSync(_docs(config, `${pkg.unscopedName}.md`), 'utf8');
for (const [all, caption, uri, ext] of content.matchAll(/\[(.*?)\]\(\.\/([^)]*)\.(.+?)\)/g)) {
content = content.replace(all, `[${caption}](${siteUrl}${uri}${ext === 'md' ? '' : ext})`);
content = content.replace(all || '', `[${caption}](${siteUrl}${uri}${ext === 'md' ? '' : ext})`);
}
writeFileSync(join(packagesPath, packageName, 'README.md'), content, 'utf8');
content = format(content, { parser: 'markdown' });
writeFileSync(_packages(config, pkg.dir, 'README.md'), content, 'utf8');
};
listPackages(config).map(({ dir, unscopedName }) => copyWithSiteUrlLinks(dir, unscopedName, config.packages));
copyWithSiteUrlLinks('index', '.', '.');
listPackages(config).map(pkg => copyWithSiteUrlLinks(pkg));
copyWithSiteUrlLinks({ dir: '..', name: 'index', unscopedName: 'index' });
}
//# sourceMappingURL=create-readme.js.map

@@ -35,3 +35,3 @@ /**

*/
export * from './build-docs';
export * from './build-docs/build-docs';
export * from './create-readme';

@@ -38,0 +38,0 @@ export * from './init';

@@ -35,3 +35,3 @@ /**

*/
export * from './build-docs';
export * from './build-docs/build-docs';
export * from './create-readme';

@@ -38,0 +38,0 @@ export * from './init';

@@ -12,3 +12,3 @@ import { UserConfig } from './common';

*/
export declare function init(config: UserConfig, force?: boolean, overrideOrigin?: string): void;
export declare function init(config: UserConfig, force?: boolean): void;
//# sourceMappingURL=init.d.ts.map
import { join, relative } from 'path';
import { getRepo, listPackages, execMacro, writeConfig, _packages, _config, _temp } from './common';
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
import { origin } from './cli.options';
/**

@@ -13,3 +14,3 @@ * Initialize docs pre-requisites:

*/
export function init(config, force = false, overrideOrigin) {
export function init(config, force = false) {
const relConfig = relative(_packages(config, 'pkg'), _config(config));

@@ -36,3 +37,5 @@ const resources = join(__dirname, '..', '..', 'resources');

...config,
git: getRepo(true, overrideOrigin),
git: getRepo(true, config.origin === origin.default
? undefined
: `origin ${config.origin} (fetch)\norigin ${config.origin} (push)`)
}, force);

@@ -39,0 +42,0 @@ template('api-extractor.base.json');

import { ProcessingConfig } from './common';
export { ProcessingConfig };
export declare type Macro = (config: ProcessingConfig, filename: string, ...args: string[]) => string;
export declare type Macros = Record<string, Macro>;
export type Macro = (config: ProcessingConfig, filename: string, ...args: string[]) => string;
export type Macros = Record<string, Macro>;
export declare class MacroError extends Error {

@@ -6,0 +6,0 @@ config: ProcessingConfig;

{
"name": "@wixc3/docs",
"version": "3.0.3",
"version": "3.0.4",
"description": "API ",

@@ -21,15 +21,14 @@ "main": "dist/cjs/index.js",

"bin": {
"docs": "bin/build-docs"
"docs": "bin/build-docs",
"tsdocs": "bin/build-docs"
},
"dependencies": {
"@microsoft/api-documenter": "^7.19.22",
"@microsoft/api-extractor": "^7.33.4",
"@microsoft/api-documenter": "^7.19.24",
"@microsoft/api-extractor": "^7.33.6",
"@microsoft/api-extractor-model": "^7.25.2",
"@wixc3/common": "^3.0.3",
"@wixc3/fs-utils": "^3.0.3",
"@wixc3/common": "^3.0.4",
"@wixc3/fs-utils": "^3.0.4",
"prettier": "^2.7.1",
"yargs": "^17.6.2"
},
"devDependencies": {
"@types/yargs": "^17.0.13"
}
}

@@ -0,55 +1,9 @@

import { join } from 'path';
import yargs from 'yargs/yargs';
import { buildDocs } from './build-docs';
import { buildDocs } from './build-docs/build-docs';
import { loadConfig } from './common';
import { createReadme } from './create-readme';
import { init } from './init';
import { base, conf, docs, force, origin, packages, siteUrl, skipAnalyze, temp } from './cli.options'
const packages = {
alias: 'p',
default: 'packages',
describe: 'workspaces (packages) directory',
string: true,
};
const skipAnalyze = {
alias: 'a',
default: false,
describe: 'Use cache analyzed api',
boolean: true,
};
const docs = {
alias: 'o',
default: '_docs',
describe: 'target directory',
string: true,
};
const conf = {
alias: 'c',
default: 'docs-conf',
describe: 'index/package/item headers and other configuration',
string: true,
};
const base = {
alias: 'b',
default: '.',
describe: 'project root',
string: true,
};
const temp = {
alias: 't',
default: 'temp',
describe: 'temp files directory',
boolean: true,
};
const force = {
alias: 'f',
default: false,
describe: 'overwrite existing configuration',
boolean: true,
};
export const siteUrl = {
alias: 's',
default: 'https://<org>.github.io/<repo>',
describe: `base URL of the project's github pages`,
string: true,
};
export function cli() {

@@ -59,4 +13,4 @@ yargs(process.argv.slice(2))

.usage('$0 <cmd> [args]')
.command('build', 'Build doc markdown from packages TSDocs', { conf, skipAnalyze }, ({ conf, skipAnalyze }) => {
buildDocs(conf, skipAnalyze);
.command('build', 'Build doc markdown from packages TSDocs', { conf, base, skipAnalyze }, ({ base, conf, skipAnalyze }) => {
buildDocs(loadConfig(join(base, conf)), { analyze: !skipAnalyze });
})

@@ -66,9 +20,9 @@ .command(

'initialize docs config and github pages action',
{ packages, conf, docs, siteUrl, base, temp, force },
({ packages, conf, docs, siteUrl, base, temp, force }) => {
init({ packages, conf, docs, siteUrl, base, temp }, force);
{ packages, conf, docs, siteUrl, base, temp, force, origin },
({ packages, conf, docs, siteUrl, base, temp, force, origin }) => {
init({ packages, conf, docs, siteUrl, base, temp, origin }, force);
}
)
.command(['readme'], 'create README.md for all the packages', { conf, siteUrl }, ({ conf, siteUrl }) => {
createReadme(conf, siteUrl);
.command('readme', 'create README.md for all the packages', { conf, base, siteUrl }, ({ conf, base, siteUrl }) => {
createReadme(loadConfig(join(base, conf)), siteUrl);
})

@@ -75,0 +29,0 @@ .demandCommand()

@@ -9,4 +9,9 @@ import { first, Nullable } from '@wixc3/common';

export type Package = {
dir: string;
name: string;
unscopedName: string;
}
export function listPackages(config: UserConfig) {
export function listPackages(config: UserConfig): Package[] {
const { base, packages } = config;

@@ -24,8 +29,8 @@ return readdirSync(join(base, packages), { withFileTypes: true })

export const getPackageByUnscopedName = (config: Config, unscopedName: string) => {
const found = listPackages(config).find(({ unscopedName: pkg }) => pkg === unscopedName)
const found = listPackages(config).find(({ unscopedName: pkg }) => pkg === unscopedName);
if (!found) {
throw new Error(`Packages not found: "${unscopedName}"`)
throw new Error(`Packages not found: "${unscopedName}"`);
}
return found
}
return found;
};

@@ -37,5 +42,4 @@ export const stripName = (name: string) => {

export const unscopedPackageName = (name: string) => name.split('/')[1] || name
export const unscopedPackageName = (name: string) => name.split('/')[1] || name;
export function parseMacro(match: RegExpMatchArray) {

@@ -98,2 +102,3 @@ const all = match[0]!;

docs: string;
origin?: string;
siteUrl?: string;

@@ -133,3 +138,3 @@ };

export function isWixDocs(config: Config) {
return config.git.github === 'https://github.com/wixplosives/core3-utils';
return config.git.github === 'https://github.com/wixplosives/core3-utils' && config.base === '.';
}

@@ -1,9 +0,8 @@

import { join } from 'path';
import { backSlash } from '@wixc3/fs-utils';
import { listPackages, loadConfig } from './common';
import { Config, listPackages, Package, _docs, _packages } from './common';
import { readFileSync, writeFileSync } from 'fs';
import { siteUrl as site } from './cli';
import { siteUrl as site } from './cli.options';
import { format } from 'prettier';
export function createReadme(conf: string, siteUrl: string) {
const config = loadConfig(conf);
export function createReadme(config: Config, siteUrl: string = site.default) {
if (siteUrl === site.default) {

@@ -13,11 +12,12 @@ siteUrl = config.git.pages;

siteUrl = backSlash(siteUrl, 'trailing');
const copyWithSiteUrlLinks = (filename: string, packageName: string, packagesPath: string) => {
let content = readFileSync(join(config.docs, `${filename}.md`), 'utf8');
const copyWithSiteUrlLinks = (pkg: Package) => {
let content = readFileSync(_docs(config, `${pkg.unscopedName}.md`), 'utf8');
for (const [all, caption, uri, ext] of content.matchAll(/\[(.*?)\]\(\.\/([^)]*)\.(.+?)\)/g)) {
content = content.replace(all!, `[${caption!}](${siteUrl}${uri!}${ext === 'md' ? '' : ext!})`);
content = content.replace(all || '', `[${caption!}](${siteUrl}${uri!}${ext === 'md' ? '' : ext!})`);
}
writeFileSync(join(packagesPath, packageName, 'README.md'), content, 'utf8');
content = format(content, { parser: 'markdown' });
writeFileSync(_packages(config, pkg.dir, 'README.md'), content, 'utf8');
};
listPackages(config).map(({dir, unscopedName}) => copyWithSiteUrlLinks(dir, unscopedName, config.packages));
copyWithSiteUrlLinks('index', '.', '.');
listPackages(config).map(pkg => copyWithSiteUrlLinks(pkg));
copyWithSiteUrlLinks({ dir: '..', name: 'index', unscopedName: 'index' });
}

@@ -35,5 +35,5 @@ /**

*/
export * from './build-docs';
export * from './build-docs/build-docs';
export * from './create-readme';
export * from './init';
export { cli } from './cli';
import { join, relative } from 'path';
import { getRepo, listPackages, execMacro, UserConfig, writeConfig, _packages, _config, _temp } from './common';
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
import { origin } from './cli.options';

@@ -16,3 +17,3 @@ export { UserConfig };

*/
export function init(config: UserConfig, force = false, overrideOrigin?: string) {
export function init(config: UserConfig, force = false) {
const relConfig = relative(_packages(config, 'pkg'), _config(config));

@@ -41,3 +42,5 @@ const resources = join(__dirname, '..', '..', 'resources');

...config,
git: getRepo(true, overrideOrigin),
git: getRepo(true, config.origin === origin.default
? undefined
: `origin ${config.origin} (fetch)\norigin ${config.origin} (push)`)
},

@@ -49,3 +52,3 @@ force

listPackages(config).map(({dir}) => {
listPackages(config).map(({ dir }) => {
const source = _config(config, 'api-extractor.json');

@@ -52,0 +55,0 @@ const target = _packages(config, dir, 'api-extractor.json');

@@ -32,4 +32,4 @@ import { readPackageJson } from '@wixc3/fs-utils';

: isWixDocs(config) && name.startsWith('docs-macros')
? '@wixc3/docs'
: getPackageByUnscopedName(config, stripName(name)).name
? '@wixc3/docs'
: getPackageByUnscopedName(config, stripName(name)).name;

@@ -36,0 +36,0 @@ /**

/* eslint-disable @typescript-eslint/no-unsafe-return */
import { expect } from 'chai';
import { buildDocs } from '../build-docs';
import { buildDocs } from '../build-docs/build-docs';
import { setup, clean, config, overwriteTemplate, readDoc, docExists, runMacro } from './test-common';

@@ -11,6 +11,6 @@ import * as macros from '../macros';

describe('buildDocs', function () {
before(setup);
before(() => setup());
before(function () {
this.timeout(15_000);
buildDocs(_config(config), false);
buildDocs(config);
});

@@ -37,3 +37,3 @@ after(clean);

buildDocs(_config(config), true);
buildDocs(config, { analyze: false, prettify: false });

@@ -47,9 +47,10 @@ expect(readDoc('index.md')).to.match(/INDEX_HEADER/);

buildDocs(_config(config), true, {
macro: (conf, docFileName, a, b) => {
expect(conf).to.deep.include(config);
expect(docFileName).to.eql('index.md');
return `MACRO${a}${b}`;
},
} as Macros);
buildDocs(config, { analyze: false, prettify: false },
{
macro: (conf, docFileName, a, b) => {
expect(conf).to.deep.include(config);
expect(docFileName).to.eql('index.md');
return `MACRO${a}${b}`;
},
} as Macros);

@@ -62,3 +63,4 @@ expect(readDoc('index.md')).to.match(/MACRO1!/);

this.timeout(10_000);
buildDocs(_config(config), false);
buildDocs(config, { analyze: false, prettify: false });
});

@@ -77,3 +79,3 @@ beforeEach(() => {

overwriteTemplate('index.md', '`[[[comment]]]`');
buildDocs(_config(config), true, { comment });
buildDocs(config, { analyze: false, prettify: false }, { comment });
const content = readDoc('index.md');

@@ -80,0 +82,0 @@ expect(content).to.match(/`\[\[\[comment\]\]\]`/g);

@@ -13,7 +13,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */

// since this this is a longish process,
// ini t is called only once, all test are checking the resulting files
// init is called only once, all test are checking the resulting files
// tests do not mutate anything
// init is executed in "setup"
this.timeout(10_000);
before(setup);
before(() => setup());
after(clean);

@@ -20,0 +20,0 @@ it('generates docs config files and templates', () => {

import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
import { join } from 'path';
import { UserConfig, _config, _docs } from '../common';
import { Config, _config, _docs } from '../common';
import { init } from '../init';
import { buildDocs } from '../build-docs';
import { buildDocs } from '../build-docs/build-docs';
import { escapeRegExp, isString, naiveStripComments } from '@wixc3/common';
import type { Macro } from '../macros.types';
export const config: UserConfig = {
export const config: Config = {
conf: 'test-conf',

@@ -15,2 +15,9 @@ base: 'docs-test-project',

temp: 'test-temp',
git: {
github: 'https://github.com/org/repo',
host: 'github.com',
org: 'org',
pages: 'https://org.github.io/repo',
repo: 'repo'
}
};

@@ -32,3 +39,3 @@

export const setup = () => {
export const setup = (_init = true) => {
clean();

@@ -41,8 +48,10 @@ // eslint-disable-next-line no-console

cpSync(join(__dirname, '..', '..', '..', 'src', 'test', 'resources', 'project'), config.base, { recursive: true });
init(
config,
true,
`origin git@github.com:org/repo.git (fetch)
origin git@github.com:org/repo.git (push)`
);
const { git: _, ...userConfig } = config;
userConfig.origin = 'git@github.com:org/repo.git';
if (_init) {
init(
userConfig,
true
);
}
};

@@ -75,3 +84,3 @@

buildDocs(_config(config), true);
buildDocs(config, { analyze: false, prettify: false });
return readDoc(filename)

@@ -78,0 +87,0 @@ .replaceAll(/>>>>>>>(.*)<<<<<<<.*$/gs, '$1')

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc