Skip to content

Commit

Permalink
chore(v4.0.0): refactor monorepo, change structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kucherenko committed May 25, 2024
1 parent 65cf600 commit 169f54a
Show file tree
Hide file tree
Showing 82 changed files with 7,056 additions and 9,192 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ docs
.cache
tmp
sandbox
/tmp/
tmp/
.turbo
build/
18 changes: 18 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"git": {
"commitMessage": "chore: release v${version}"
},
"github": {
"release": true,
"releaseName": "v${version}"
},
"npm": {
"publish": false
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "conventionalcommits",
"infile": "CHANGELOG.md"
}
}
}
12 changes: 0 additions & 12 deletions .snyk

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions apps/jscpd/bin/jscpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../dist/jscpd')
10 changes: 10 additions & 0 deletions apps/jscpd/bin/jscpd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {jscpd} from "../src";

(async () => {
try {
await jscpd(process.argv, process.exit)
} catch(e) {
console.log(e);
process.exit(1);
}
})()
7 changes: 7 additions & 0 deletions apps/jscpd/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/nodemon.json",
"watch": ["./src/**"],
"ignoreRoot": [],
"ext": "ts,js",
"exec": "pnpm build"
}
37 changes: 20 additions & 17 deletions packages/jscpd/package.json → apps/jscpd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jscpd",
"version": "3.5.10",
"version": "4.0.0-rc.0",
"description": "detector of copy/paste in files",
"author": "Andrey Kucherenko <[email protected]>",
"homepage": "https://github.com/kucherenko/jscpd#readme",
Expand All @@ -26,28 +26,31 @@
"url": "git+ssh://[email protected]/kucherenko/jscpd.git"
},
"scripts": {
"build": "yarn clean && yarn compile",
"clean": "rm -rf ./dist",
"compile": "tsc -p tsconfig.build.json",
"prepare": "ts-node ../../build-utils/publish-util.ts ./package.json dist/index",
"postpublish": "ts-node ../../build-utils/publish-util.ts ./package.json src/index",
"prepublishOnly": "yarn build"
"build": "tsup",
"dev": "nodemon",
"test": "vitest run",
"typecheck": "tsc",
"cleanup": "rimraf ./dist .turbo"
},
"dependencies": {
"@jscpd/core": "^3.5.4",
"@jscpd/finder": "^3.5.10",
"@jscpd/html-reporter": "^3.5.10",
"@jscpd/tokenizer": "^3.5.4",
"colors": "1.4.0",
"commander": "^5.0.0",
"fs-extra": "^9.1.0",
"@jscpd/core": "workspace:*",
"@jscpd/finder": "workspace:*",
"@jscpd/html-reporter": "workspace:*",
"@jscpd/tokenizer": "workspace:*",
"colors": "^1.4.0",
"commander": "^12.1.0",
"fs-extra": "^11.2.0",
"gitignore-to-glob": "^0.3.0"
},
"devDependencies": {
"@types/colors": "^1.2.1",
"@types/fs-extra": "^8.1.0",
"@tsconfig/node20": "^20.1.4",
"@types/fs-extra": "^11.0.4",
"jscpd-badge-reporter": "^1.1.3",
"ts-node": "^8.8.2"
"nodemon": "^3.1.0",
"ts-node": "^10.9.2",
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"vitest": "^1.6.0"
},
"preferGlobal": true,
"gitHead": "87a118f80343288c0099a4e3e47ccd875476bf6c"
Expand Down
6 changes: 3 additions & 3 deletions packages/jscpd/src/index.ts → apps/jscpd/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getDefaultOptions, IClone, IOptions, IStore, Statistic } from '@jscpd/core';
import {getDefaultOptions, IClone, IMapFrame, IOptions, IStore, Statistic} from '@jscpd/core';
import { grey, italic } from 'colors/safe';
import { EntryWithContent, getFilesToDetect, InFilesDetector } from '@jscpd/finder';
import { initCli, initOptionsFromCli } from './init';
import { printFiles, printOptions, printSupportedFormat } from './print';
import { createHash } from "crypto";
import { getStore } from './init/store';
import { getSupportedFormats, IMapFrame, Tokenizer } from '@jscpd/tokenizer';
import { getSupportedFormats, Tokenizer } from '@jscpd/tokenizer';
import { registerReporters } from './init/reporters';
import { registerSubscribers } from './init/subscribers';
import { registerHooks } from './init/hooks';
Expand Down Expand Up @@ -69,7 +69,7 @@ export async function jscpd(argv: string[], exitCallback?: (code: number) => {})
return detectClones(options, store)
.then((clones) => {
if (clones.length > 0) {
exitCallback?.(options.exitCode)
exitCallback?.(options.exitCode || 0)
}
return clones;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ export function initCli(packageJson, argv: string[]): Command {
.option('--exitCode [number]', 'exit code to use when code duplications are detected')

cli.parse(argv);
return cli as Command;
return cli satisfies Command;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions apps/jscpd/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"outDir": "dist/src",
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "bundler",
"allowUnusedLabels": false,
"allowUnreachableCode": false,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"sourceMap": true,
"resolveJsonModule": true
},
"include": ["src"],
"exclude": ["dist", "bundle", "node_modules"],
"ts-node": {
// these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": {
"module": "commonjs"
}
},
}
8 changes: 8 additions & 0 deletions apps/jscpd/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'tsup'

export default defineConfig({
entry: ['bin/jscpd.ts'],
splitting: false,
sourcemap: false,
clean: true,
})
2 changes: 0 additions & 2 deletions codecov.yml

This file was deleted.

8 changes: 0 additions & 8 deletions lerna.json

This file was deleted.

81 changes: 11 additions & 70 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,19 @@
"private": true,
"npmClient": "yarn",
"useWorkspaces": true,
"version": "3.3.0-rc.0",
"version": "4.0.0-rc.0",
"scripts": {
"commit": "npx git-cz",
"bootstrap": "lerna bootstrap",
"postinstall": "yarn bootstrap",
"clean": "lerna run clean",
"build": "lerna run build",
"pub": "lerna publish",
"test": "nyc yarn run test:unit",
"test:unit": "mocha -r source-map-support/register -r ts-node/register packages/*/__tests__/**/*.test.ts",
"coverage": "run-s build test cov:html cov:check",
"lint": "eslint --cache --ext .ts packages/*/src",
"cov": "run-s build test cov:html && open coverage/lcov-report/index.html",
"cov:html": "nyc report --reporter=lcov",
"cov:check": "nyc report && nyc check-coverage --lines 90 --functions 90 --branches 77",
"doc": "run-s doc:html && open docs/index.html",
"doc:html": "typedoc --out ./docs ./packages",
"doc:publish": "gh-pages -m \"[ci skip] Updates\" -d docs",
"reset": "git clean -dfx && git reset --hard && yarn",
"all": "run-s reset test cov:check doc:html",
"changelog": "lerna-changelog"
},
"nyc": {
"reporter": [
"lcov"
],
"include": [
"packages/*/src/**/*.ts"
],
"exclude": [
"packages/examples/**"
],
"extends": "@istanbuljs/nyc-config-typescript",
"all": true
},
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/kucherenko/jscpd.git"
"build": "turbo run build",
"generate": "turbo run generate",
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"lint:fix": "turbo run lint:fix",
"test": "turbo run test",
"cleanup": "turbo run cleanup"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"chai": "^4.2.0",
"conventional-changelog-cli": "^2.0.31",
"cz-conventional-changelog": "^3.1.0",
"eslint": "^6.8.0",
"eslint-plugin-sonarjs": "^0.5.0",
"gh-pages": "^2.2.0",
"git-cz": "^4.3.1",
"lerna": "^3.20.2",
"lerna-changelog": "^1.0.1",
"mocha": "^7.1.2",
"npm-run-all": "^4.1.5",
"nyc": "^15.0.1",
"open-cli": "^5.0.0",
"proxyquire": "^2.1.3",
"sinon": "^9.0.2",
"source-map-support": "^0.5.19",
"typedoc": "~0.17.6",
"typedoc-plugin-lerna-packages": "~0.3.0",
"typescript": "^3.8.3"
"@changesets/cli": "^2.27.3",
"turbo": "^1.13.3"
},
"workspaces": [
"packages/*"
],
"readmeFilename": "README.md",
"dependencies": {
"codecov": "^3.7.2"
}
"readmeFilename": "README.md"
}
7 changes: 7 additions & 0 deletions packages/badge-reporter/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/nodemon.json",
"watch": ["./src/**"],
"ignoreRoot": [],
"ext": "ts,js",
"exec": "pnpm typecheck && pnpm build"
}
38 changes: 26 additions & 12 deletions packages/badge-reporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,24 @@
"author": "Andrey Kucherenko <[email protected]>",
"homepage": "https://github.com/kucherenko/jscpd#readme",
"license": "MIT",
"main": "src/index",
"types": "src/index",
"main": "dist/index.js",
"module": "dist/index.mjs",
"typings": "dist/index.d.mts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./README.md": "./README.md"
},
"scripts": {
"build": "tsup",
"dev": "nodemon",
"test": "vitest run",
"typecheck": "tsc",
"cleanup": "rimraf ./dist .turbo"
},
"directories": {
"src": "src",
"test": "__tests__"
Expand All @@ -27,19 +43,17 @@
"type": "git",
"url": "git+ssh://[email protected]/kucherenko/jscpd.git"
},
"scripts": {
"build": "yarn clean && yarn compile",
"clean": "rm -rf ./dist",
"compile": "tsc -p tsconfig.build.json",
"prepare": "ts-node ../../build-utils/publish-util.ts ./package.json dist/index",
"postpublish": "ts-node ../../build-utils/publish-util.ts ./package.json src/index",
"prepublishOnly": "yarn build"
},
"bugs": {
"url": "https://github.com/kucherenko/jscpd/issues"
},
"dependencies": {
"badgen": "^3.2.2",
"fs-extra": "^9.0.1"
"badgen": "^3.2.3",
"fs-extra": "^11.2.0"
},
"devDependencies": {
"@tsconfig/node20": "^20.1.4",
"@types/node": "^20.12.12",
"nodemon": "^3.1.0",
"tsup": "^8.0.2"
}
}
9 changes: 9 additions & 0 deletions packages/badge-reporter/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {defineConfig} from 'tsup'

export default defineConfig({
entry: ['src/index.ts'],
splitting: true,
sourcemap: true,
clean: true,
format: ['esm', 'cjs']
})
7 changes: 7 additions & 0 deletions packages/core/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/nodemon.json",
"watch": ["./src/**"],
"ignoreRoot": [],
"ext": "ts,js",
"exec": "pnpm typecheck && pnpm build"
}
Loading

0 comments on commit 169f54a

Please sign in to comment.