Skip to content

Commit

Permalink
setup verdaccio
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton committed Sep 1, 2024
1 parent ee14bfb commit eb900fd
Show file tree
Hide file tree
Showing 54 changed files with 1,057 additions and 6,983 deletions.
35 changes: 35 additions & 0 deletions .eslintrc.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
]
}
7 changes: 2 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand All @@ -23,13 +21,12 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
]
],
"extends": ["./.eslintrc.base.json"]
}
2 changes: 1 addition & 1 deletion .verdaccio/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ packages:
proxy: npmjs

# log settings
logs:
log:
type: stdout
format: pretty
level: warn
Expand Down
30 changes: 30 additions & 0 deletions e2e/cli-e2e-original/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"extends": ["../../.eslintrc.json", "../../.eslintrc.base.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"]
}
]
}
}
]
}
3 changes: 3 additions & 0 deletions e2e/cli-e2e-original/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cli-e2e-original

End-to-end tests for the `cli` library.
20 changes: 20 additions & 0 deletions e2e/cli-e2e-original/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "cli-e2e-original",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "projects/cli-e2e-original/test",
"projectType": "library",
"tags": [],
"targets": {
"e2e": {
"executor": "@nx/vite:test",
"inputs": [
"default",
"^production"
],
"outputs": ["{options.reportsDirectory}"],
"options": {
"reportsDirectory": "../../coverage/projects/cli-e2e-original"
}
}
}
}
59 changes: 59 additions & 0 deletions e2e/cli-e2e-original/setup/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

import {join} from "node:path";
import {executeProcess} from "test-utils";
import {startVerdaccioServer} from "../../../tools/utils/registry";

const isVerbose: boolean = true;// process.env.NX_VERBOSE_LOGGING === 'true' ?? false;
let stopRegistry;

export async function setup() {

// start registry
stopRegistry = await startVerdaccioServer({
targetName: 'local-registry',
storage: join('tmp', 'cli-source', 'local-registry', 'storage'),
verbose: isVerbose,
port: '4873'
});


// package publish all projects
await executeProcess({
command: 'nx',
args: ['run-many', '-t=nx-release-publish', '--registry=http://localhost:4873'],
observer: {
onStdout: stdout => {
if (isVerbose) {
console.info(stdout)
}
},
onStderr: stdout => {
if (isVerbose) {
console.error(stdout)
}
}
},
});
// package install all projects
await executeProcess({
command: 'nx',
args: ['run-many', '-t=npm-install', '--registry=http://localhost:4873'],
observer: {
onStdout: stdout => {
if (isVerbose) {
console.info(stdout)
}
},
onStderr: stdout => {
if (isVerbose) {
console.error(stdout)
}
}
},
});
}

export async function teardown() {
// stop registry
stopRegistry()
}
30 changes: 30 additions & 0 deletions e2e/cli-e2e-original/test/cli.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {dirname, join} from 'node:path';
import {afterEach, describe, expect, it} from "vitest";
import {mkdir, readFile, rm, writeFile} from "node:fs/promises";
import {execSync} from "node:child_process";

describe('CLI command - sort', () => {
const baseDir = 'tmp/cli/sort';

afterEach(async () => {
await rm(baseDir, {recursive: true, force: true});
});

it('should execute CLI command sort when param file is given', async () => {
const testPath = join(baseDir, 'file-sort', 'users.json');
await mkdir(dirname(testPath), {recursive: true});
await writeFile(testPath, JSON.stringify([
{name: 'Michael'},
{name: 'Alice'},
]));

expect(() => execSync(`npx @org/cli sort --file="${testPath}"`)).toThrow('Command failed: npx @org/cli sort --file="tmp/cli/sort/file-sort/users.json"');
/*
const content = (await readFile(testPath)).toString();
expect(JSON.parse(content)).toEqual([
{name: 'Alice'},
{name: 'Michael'},
]);
*/
});
});
19 changes: 19 additions & 0 deletions e2e/cli-e2e-original/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "esnext",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.spec.json"
}
]
}
26 changes: 26 additions & 0 deletions e2e/cli-e2e-original/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"vite.config.ts",
"vitest.config.ts",
"test/**/*.test.ts",
"test/**/*.spec.ts",
"test/**/*.test.tsx",
"test/**/*.spec.tsx",
"test/**/*.test.js",
"test/**/*.spec.js",
"test/**/*.test.jsx",
"test/**/*.spec.jsx",
"test/**/*.d.ts"
]
}
28 changes: 28 additions & 0 deletions e2e/cli-e2e-original/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineConfig } from 'vite';

import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/projects/cli',

plugins: [nxViteTsPaths()],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

test: {
globals: true,
cache: { dir: '../../node_modules/.vitest' },
environment: 'node',
include: ['test/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
globalSetup: ['./setup/global-setup.ts'],
coverage: {
reportsDirectory: '../../coverage/projects/cli',
provider: 'v8',
},
},
});
59 changes: 59 additions & 0 deletions e2e/cli-e2e/setup/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

import {join} from "node:path";
import {executeProcess} from "test-utils";
import {startVerdaccioServer} from "../../../tools/utils/registry";

const isVerbose: boolean = true;// process.env.NX_VERBOSE_LOGGING === 'true' ?? false;
let stopRegistry;

export async function setup() {

// start registry
stopRegistry = await startVerdaccioServer({
targetName: 'local-registry',
storage: join('tmp', 'cli-source', 'local-registry', 'storage'),
verbose: isVerbose,
port: '4873'
});


// package publish all projects
await executeProcess({
command: 'nx',
args: ['run-many', '-t=nx-release-publish', '--registry=http://localhost:4873'],
observer: {
onStdout: stdout => {
if (isVerbose) {
console.info(stdout)
}
},
onStderr: stdout => {
if (isVerbose) {
console.error(stdout)
}
}
},
});
// package install all projects
await executeProcess({
command: 'nx',
args: ['run-many', '-t=npm-install', '--registry=http://localhost:4873'],
observer: {
onStdout: stdout => {
if (isVerbose) {
console.info(stdout)
}
},
onStderr: stdout => {
if (isVerbose) {
console.error(stdout)
}
}
},
});
}

export async function teardown() {
// stop registry
stopRegistry()
}
Loading

0 comments on commit eb900fd

Please sign in to comment.