docs(core): fix internal package dependencies so nx.dev is not affected by their changes (#5878)
This commit is contained in:
parent
d3992e9453
commit
9838d2dd46
@ -1,6 +1,7 @@
|
|||||||
const nxPreset = require('@nrwl/jest/preset');
|
const nxPreset = require('@nrwl/jest/preset');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...nxPreset,
|
...nxPreset,
|
||||||
|
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
||||||
displayName: 'nx-dev-data-access-documents',
|
displayName: 'nx-dev-data-access-documents',
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
|
|||||||
@ -1,16 +1,22 @@
|
|||||||
import { DocumentsApi } from './documents.api';
|
import { DocumentsApi } from './documents.api';
|
||||||
import type { DocumentMetadata } from './documents.models';
|
import type { DocumentMetadata } from './documents.models';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { readJsonFile } from '@nrwl/workspace';
|
import fs from 'fs';
|
||||||
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root';
|
|
||||||
|
|
||||||
const archiveRootPath = join(appRootPath, 'nx-dev/nx-dev/public/documentation');
|
const archiveRootPath = join(
|
||||||
|
process.env.WORKSPACE_ROOT,
|
||||||
|
'nx-dev/nx-dev/public/documentation'
|
||||||
|
);
|
||||||
const documentsCache = new Map<string, DocumentMetadata[]>([
|
const documentsCache = new Map<string, DocumentMetadata[]>([
|
||||||
['latest', readJsonFile(join(archiveRootPath, 'latest', 'map.json'))],
|
['latest', readJsonFile(join(archiveRootPath, 'latest', 'map.json'))],
|
||||||
['previous', readJsonFile(join(archiveRootPath, 'previous', 'map.json'))],
|
['previous', readJsonFile(join(archiveRootPath, 'previous', 'map.json'))],
|
||||||
]);
|
]);
|
||||||
const versionsData = readJsonFile(join(archiveRootPath, 'versions.json'));
|
const versionsData = readJsonFile(join(archiveRootPath, 'versions.json'));
|
||||||
|
|
||||||
|
function readJsonFile(f) {
|
||||||
|
return JSON.parse(fs.readFileSync(f).toString());
|
||||||
|
}
|
||||||
|
|
||||||
describe('DocumentsApi', () => {
|
describe('DocumentsApi', () => {
|
||||||
const api = new DocumentsApi(versionsData, documentsCache);
|
const api = new DocumentsApi(versionsData, documentsCache);
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root';
|
|
||||||
|
|
||||||
export const archiveRootPath = join(
|
export const archiveRootPath = join(
|
||||||
appRootPath,
|
process.env.WORKSPACE_ROOT,
|
||||||
'nx-dev/nx-dev/public/documentation'
|
'nx-dev/nx-dev/public/documentation'
|
||||||
);
|
);
|
||||||
export const previewRootPath = join(appRootPath, 'docs');
|
export const previewRootPath = join(process.env.WORKSPACE_ROOT, 'docs');
|
||||||
|
|
||||||
export function extractTitle(markdownContent: string): string | null {
|
export function extractTitle(markdownContent: string): string | null {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -4,16 +4,22 @@ import {
|
|||||||
DocumentsApi,
|
DocumentsApi,
|
||||||
} from '@nrwl/nx-dev/data-access-documents';
|
} from '@nrwl/nx-dev/data-access-documents';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root';
|
import * as fs from 'fs';
|
||||||
import { readJsonFile } from '@nrwl/workspace';
|
|
||||||
|
|
||||||
const archiveRootPath = join(appRootPath, 'nx-dev/nx-dev/public/documentation');
|
const archiveRootPath = join(
|
||||||
|
process.env.WORKSPACE_ROOT,
|
||||||
|
'nx-dev/nx-dev/public/documentation'
|
||||||
|
);
|
||||||
const documentsCache = new Map<string, DocumentMetadata[]>([
|
const documentsCache = new Map<string, DocumentMetadata[]>([
|
||||||
['latest', readJsonFile(join(archiveRootPath, 'latest', 'map.json'))],
|
['latest', readJsonFile(join(archiveRootPath, 'latest', 'map.json'))],
|
||||||
['previous', readJsonFile(join(archiveRootPath, 'previous', 'map.json'))],
|
['previous', readJsonFile(join(archiveRootPath, 'previous', 'map.json'))],
|
||||||
]);
|
]);
|
||||||
const versionsData = readJsonFile(join(archiveRootPath, 'versions.json'));
|
const versionsData = readJsonFile(join(archiveRootPath, 'versions.json'));
|
||||||
|
|
||||||
|
function readJsonFile(f) {
|
||||||
|
return JSON.parse(fs.readFileSync(f).toString());
|
||||||
|
}
|
||||||
|
|
||||||
describe('MenuApi', () => {
|
describe('MenuApi', () => {
|
||||||
const docsApi = new DocumentsApi(versionsData, documentsCache);
|
const docsApi = new DocumentsApi(versionsData, documentsCache);
|
||||||
const api = new MenuApi(docsApi);
|
const api = new MenuApi(docsApi);
|
||||||
|
|||||||
1
nx-dev/data-access-documents/src/test-setup.ts
Normal file
1
nx-dev/data-access-documents/src/test-setup.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
process.env.WORKSPACE_ROOT = process.cwd();
|
||||||
@ -5,7 +5,7 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"outDir": "../../dist/out-tsc",
|
"outDir": "../../dist/out-tsc",
|
||||||
"types": []
|
"types": ["node"]
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts"],
|
"include": ["**/*.ts"],
|
||||||
"exclude": ["**/*.spec.ts"]
|
"exclude": ["**/*.spec.ts"]
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
const { join } = require('path');
|
||||||
|
// nx-ignore-next-line
|
||||||
const withNx = require('@nrwl/next/plugins/with-nx');
|
const withNx = require('@nrwl/next/plugins/with-nx');
|
||||||
|
|
||||||
module.exports = withNx({});
|
module.exports = withNx({
|
||||||
|
env: {
|
||||||
|
WORKSPACE_ROOT: join(__dirname, '../..'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root';
|
|
||||||
|
|
||||||
import * as send from 'send';
|
import * as send from 'send';
|
||||||
|
|
||||||
// Repeated here since `data-access-documents` isn't available at runtime.
|
// Repeated here since `data-access-documents` isn't available at runtime.
|
||||||
const previewRootPath = join(appRootPath, 'docs');
|
const previewRootPath = join(process.env.WORKSPACE_ROOT, 'docs');
|
||||||
|
|
||||||
export default function (req: NextApiRequest, res: NextApiResponse) {
|
export default function (req: NextApiRequest, res: NextApiResponse) {
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
// nx-ignore-next-line
|
||||||
const nxJson = require('@nrwl/workspace').readNxJson();
|
const nxJson = require('@nrwl/workspace').readNxJson();
|
||||||
|
// nx-ignore-next-line
|
||||||
const workspaceJson = require('@nrwl/workspace').readWorkspaceJson();
|
const workspaceJson = require('@nrwl/workspace').readWorkspaceJson();
|
||||||
|
|
||||||
function getProjectNameWithTag(projectsJson, tag) {
|
function getProjectNameWithTag(projectsJson, tag) {
|
||||||
|
|||||||
6
nx.json
6
nx.json
@ -119,7 +119,8 @@
|
|||||||
"tags": ["core"]
|
"tags": ["core"]
|
||||||
},
|
},
|
||||||
"nx-dev": {
|
"nx-dev": {
|
||||||
"tags": ["scope:nx-dev", "type:app"]
|
"tags": ["scope:nx-dev", "type:app"],
|
||||||
|
"implicitDependencies": ["docs"]
|
||||||
},
|
},
|
||||||
"nx-dev-e2e": {
|
"nx-dev-e2e": {
|
||||||
"tags": ["scope:nx-dev", "type:e2e"],
|
"tags": ["scope:nx-dev", "type:e2e"],
|
||||||
@ -134,7 +135,8 @@
|
|||||||
"nx-dev-data-access-documents": {
|
"nx-dev-data-access-documents": {
|
||||||
"tags": ["scope:nx-dev", "type:data-access"]
|
"tags": ["scope:nx-dev", "type:data-access"]
|
||||||
},
|
},
|
||||||
"nx-dev-feature-search": { "tags": ["scope:nx-dev", "type:feature"] }
|
"nx-dev-feature-search": { "tags": ["scope:nx-dev", "type:feature"] },
|
||||||
|
"docs": { "tags": ["scope:nx-dev"] }
|
||||||
},
|
},
|
||||||
"affected": { "defaultBase": "master" }
|
"affected": { "defaultBase": "master" }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2369,6 +2369,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"docs": {
|
||||||
|
"root": "docs",
|
||||||
|
"sourceRoot": "docs",
|
||||||
|
"projectType": "library"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cli": {
|
"cli": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user