docs(core): fix internal package dependencies so nx.dev is not affected by their changes (#5878)

This commit is contained in:
Jack Hsu 2021-06-03 14:13:28 -04:00 committed by GitHub
parent d3992e9453
commit 9838d2dd46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 43 additions and 16 deletions

1
.nxignore Normal file
View File

@ -0,0 +1 @@
nx-dev/**/jest.config.js

View File

@ -1,6 +1,7 @@
const nxPreset = require('@nrwl/jest/preset');
module.exports = {
...nxPreset,
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
displayName: 'nx-dev-data-access-documents',
globals: {
'ts-jest': {

View File

@ -1,16 +1,22 @@
import { DocumentsApi } from './documents.api';
import type { DocumentMetadata } from './documents.models';
import { join } from 'path';
import { readJsonFile } from '@nrwl/workspace';
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root';
import fs from 'fs';
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[]>([
['latest', readJsonFile(join(archiveRootPath, 'latest', 'map.json'))],
['previous', readJsonFile(join(archiveRootPath, 'previous', 'map.json'))],
]);
const versionsData = readJsonFile(join(archiveRootPath, 'versions.json'));
function readJsonFile(f) {
return JSON.parse(fs.readFileSync(f).toString());
}
describe('DocumentsApi', () => {
const api = new DocumentsApi(versionsData, documentsCache);

View File

@ -1,11 +1,10 @@
import { join } from 'path';
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root';
export const archiveRootPath = join(
appRootPath,
process.env.WORKSPACE_ROOT,
'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 {
return (

View File

@ -4,16 +4,22 @@ import {
DocumentsApi,
} from '@nrwl/nx-dev/data-access-documents';
import { join } from 'path';
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root';
import { readJsonFile } from '@nrwl/workspace';
import * as fs from 'fs';
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[]>([
['latest', readJsonFile(join(archiveRootPath, 'latest', 'map.json'))],
['previous', readJsonFile(join(archiveRootPath, 'previous', 'map.json'))],
]);
const versionsData = readJsonFile(join(archiveRootPath, 'versions.json'));
function readJsonFile(f) {
return JSON.parse(fs.readFileSync(f).toString());
}
describe('MenuApi', () => {
const docsApi = new DocumentsApi(versionsData, documentsCache);
const api = new MenuApi(docsApi);

View File

@ -0,0 +1 @@
process.env.WORKSPACE_ROOT = process.cwd();

View File

@ -5,7 +5,7 @@
"esModuleInterop": true,
"resolveJsonModule": true,
"outDir": "../../dist/out-tsc",
"types": []
"types": ["node"]
},
"include": ["**/*.ts"],
"exclude": ["**/*.spec.ts"]

View File

@ -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');
module.exports = withNx({});
module.exports = withNx({
env: {
WORKSPACE_ROOT: join(__dirname, '../..'),
},
});

View File

@ -1,11 +1,10 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { join } from 'path';
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root';
import * as send from 'send';
// 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) {
return new Promise<void>((resolve) => {

View File

@ -1,5 +1,7 @@
const path = require('path');
// nx-ignore-next-line
const nxJson = require('@nrwl/workspace').readNxJson();
// nx-ignore-next-line
const workspaceJson = require('@nrwl/workspace').readWorkspaceJson();
function getProjectNameWithTag(projectsJson, tag) {

View File

@ -119,7 +119,8 @@
"tags": ["core"]
},
"nx-dev": {
"tags": ["scope:nx-dev", "type:app"]
"tags": ["scope:nx-dev", "type:app"],
"implicitDependencies": ["docs"]
},
"nx-dev-e2e": {
"tags": ["scope:nx-dev", "type:e2e"],
@ -134,7 +135,8 @@
"nx-dev-data-access-documents": {
"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" }
}

View File

@ -2369,6 +2369,11 @@
}
}
}
},
"docs": {
"root": "docs",
"sourceRoot": "docs",
"projectType": "library"
}
},
"cli": {