Skip to content

Commit

Permalink
Wrapping up
Browse files Browse the repository at this point in the history
  • Loading branch information
vdiez committed Nov 12, 2024
1 parent 065a533 commit 02e2a0c
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 81 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Maven
target/
bin/

lib/
node_modules/
Expand Down
8 changes: 4 additions & 4 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import textReplace from 'esbuild-plugin-text-replace';
import { copy } from 'esbuild-plugin-copy';

await esbuild.build({
entryPoints: ['./bin/server.mjs'],
outfile: './build/server.cjs',
entryPoints: ['./server.mjs'],
outfile: './bin/server.cjs',
format: 'cjs',
bundle: true,
external: ['eslint/lib/util/glob-util'],
Expand All @@ -30,11 +30,11 @@ await esbuild.build({
assets: [
{
from: ['./node_modules/typescript/lib/*.d.ts'],
to: ['./build/'],
to: ['./bin/'],
},
{
from: ['./packages/jsts/src/parsers/estree.proto'],
to: ['./build/'],
to: ['./bin/'],
},
],
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void start(Path dest) throws IOException {
port = findOpenPort();
String[] cmd = {
"node",
dest.resolve("package/bin/server.mjs").toString(),
dest.resolve("package/bin/server.cjs").toString(),
String.valueOf(port),
"127.0.0.1",
temp.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import org.apache.commons.lang.StringUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -86,7 +88,56 @@ class JsTsRulingTest {

public static Stream<Arguments> ruling() {
return Stream.of(
jsTsProject("fireact")
jsTsProject("amplify", "external/**", "test"),
jsTsProject("angular.js", "src/ngLocale/**, i18n/**", "test"),
jsTsProject("backbone", "test"),
jsTsProject("es5-shim", "tests"),
jsTsProject("fireact"),
jsTsProject("ace"),
jsTsProject("ecmascript6-today"),
jsTsProject("expressionist.js"),
jsTsProject("Ghost"),
jsTsProject("http"),
jsTsProject("reddit-mobile"),
jsTsProject("redux"),
jsTsProject("router"),
jsTsProject("snoode"),
jsTsProject("sonar-web"),
jsTsProject("templating"),
jsTsProject("watchtower.js"),
jsTsProject("jira-clone"),
jsTsProject("jquery", "test"),
jsTsProject("jshint", "tests"),
jsTsProject("jStorage", "tests"),
jsTsProject("knockout", "spec"),
jsTsProject("mootools-core", "Specs"),
jsTsProject("ocanvas", "build/**", ""),
jsTsProject("p5.js", "test"),
jsTsProject("paper.js", "gulp/jsdoc/**, packages/**", "test"),
jsTsProject("prototype", "test"),
jsTsProject("qunit", "test"),
jsTsProject("react-cloud-music"),
jsTsProject("sizzle", "external/**", "test"),
jsTsProject("underscore", "test"),
jsTsProject("ag-grid", "spec"),
jsTsProject("ant-design", "tests"), // todo: many dirs **/__tests__
jsTsProject("console"), // todo: many dirs **/__tests__
jsTsProject("courselit", ".yarn/**", ""),
jsTsProject("desktop", "app/test"),
jsTsProject("eigen"), // todo
jsTsProject("fireface"),
jsTsProject("ionic2-auth"),
jsTsProject("Joust"), // todo: files **/*.spec.ts
jsTsProject("moose"),
jsTsProject("postgraphql"), // todo: many dirs **/__tests__
jsTsProject("prettier-vscode"),
jsTsProject("rxjs", "spec"),
jsTsProject("searchkit"), // todo
jsTsProject("TypeScript", "src/harness/unittests"),
jsTsProject("vuetify"),
jsTsProject("it-tools"),
jsTsProject("yaml", "../sources/yaml", "", ""),
jsTsProject("file-for-rules", "../sources/jsts/custom", "", "tests")
);
}

Expand Down Expand Up @@ -206,6 +257,7 @@ private static void installScanner() {

@ParameterizedTest
@MethodSource
@Execution(ExecutionMode.CONCURRENT)
void ruling(String project, String sourceDir, String exclusions, String testDir)
throws Exception {
runRulingTest(project, sourceDir, exclusions, testDir);
Expand Down Expand Up @@ -281,13 +333,13 @@ private static void instantiateTemplateRule(
Arrays.asList(
(
"name=\"" +
instantiationKey +
"\";key=\"" +
instantiationKey +
"\";markdown_description=\"" +
instantiationKey +
"\";" +
params
instantiationKey +
"\";key=\"" +
instantiationKey +
"\";markdown_description=\"" +
instantiationKey +
"\";" +
params
).split(";", 0)
)
)
Expand Down Expand Up @@ -319,8 +371,8 @@ private static void instantiateTemplateRule(
} else {
throw new IllegalStateException(
"Could not retrieve profile key : Template rule " +
ruleTemplateKey +
" has not been activated"
ruleTemplateKey +
" has not been activated"
);
}
}
Expand All @@ -336,4 +388,4 @@ static WsClient newAdminWsClient(Orchestrator orchestrator) {
.build()
);
}
}
}
47 changes: 2 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
"bridge:compile": "tsc -b packages profiling && npm run _:bridge:copy-protofiles",
"bridge:test": "tsx --tsconfig packages/tsconfig.test.json --test --test-reporter spec --test-reporter-destination stdout \"packages/*/src/rules/*[!node_modules]/**/*.test.ts\" \"packages/*[!ruling]/tests/**/*.test.ts\"",
"bridge:test:cov": "odz run npm run bridge:test || true && odz report --reporters=text-lcov > lcov.info",
"bridge:bundle": "node esbuild.mjs",
"bridge:build": "npm run bridge:build:fast && npm run bridge:test",
"bridge:build:cov": "npm run bridge:build:fast && npm run bridge:test:cov",
"bridge:build:fast": "npm ci && npm run _:bridge:clear && npm run bridge:compile",
"bridge:build:fast": "npm ci && npm run _:bridge:clear && npm run bridge:compile && npm run bridge:bundle",
"bbf": "npm run bridge:build:fast",
"plugin:build": "mvn install && npm run update-ruling-data",
"plugin:build:fast": "mvn install -DskipTests && npm run update-ruling-data",
Expand Down Expand Up @@ -140,49 +141,6 @@
"vue-eslint-parser": "9.4.3",
"yaml": "2.5.1"
},
"bundleDependencies": [
"@typescript-eslint/eslint-plugin",
"@typescript-eslint/utils",
"@typescript-eslint/parser",
"@babel/core",
"@babel/eslint-parser",
"@babel/plugin-proposal-decorators",
"@babel/preset-env",
"@babel/preset-flow",
"@babel/preset-react",
"@eslint-community/regexpp",
"builtin-modules",
"bytes",
"eslint",
"eslint-plugin-import",
"eslint-plugin-jsx-a11y",
"eslint-plugin-react",
"eslint-plugin-react-hooks",
"express",
"form-data",
"functional-red-black-tree",
"htmlparser2",
"jsx-ast-utils",
"lodash.clone",
"minimatch",
"module-alias",
"postcss",
"postcss-html",
"postcss-less",
"postcss-sass",
"postcss-scss",
"postcss-syntax",
"postcss-value-parser",
"protobufjs",
"run-node",
"semver",
"scslre",
"stylelint",
"tmp",
"vue-eslint-parser",
"typescript",
"yaml"
],
"prettier": {
"printWidth": 100,
"trailingComma": "all",
Expand All @@ -191,7 +149,6 @@
"endOfLine": "lf"
},
"files": [
"lib/",
"bin/"
]
}
2 changes: 1 addition & 1 deletion packages/bridge/tests/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('router', () => {
const fixtures = path.join(import.meta.dirname, 'fixtures', 'router');
const port = 0;
let closePromise: Promise<void>;
const workerPath = path.join(import.meta.dirname, '..', '..', '..', 'bin', 'server.mjs');
const workerPath = path.join(import.meta.dirname, '..', '..', '..', 'server.mjs');

let server: http.Server;

Expand Down
2 changes: 1 addition & 1 deletion packages/bridge/tests/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import assert from 'node:assert';
import { getContext, setContext } from '../../shared/src/helpers/context.js';
import { createWorker } from '../../shared/src/helpers/worker.js';

const workerPath = path.join(import.meta.dirname, '..', '..', '..', 'bin', 'server.mjs');
const workerPath = path.join(import.meta.dirname, '..', '..', '..', 'server.mjs');

describe('server', () => {
const port = 0;
Expand Down
20 changes: 6 additions & 14 deletions bin/server.mjs → server.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env node
import { isMainThread } from 'node:worker_threads';
import * as server from '../lib/bridge/src/server.js';
import * as server from './lib/bridge/src/server.js';
import path from 'path';
import * as context from '../lib/shared/src/helpers/context.js';
import * as context from './lib/shared/src/helpers/context.js';
import { pathToFileURL } from 'node:url';
import { createWorker } from '../lib/shared/src/helpers/worker.js';
import { getContext } from '../lib/shared/src/helpers/context.js';
import { createWorker } from './lib/shared/src/helpers/worker.js';
import { getContext } from './lib/shared/src/helpers/context.js';

// import containing code which is only executed if it's a child process
import '../lib/bridge/src/worker.js';
import './lib/bridge/src/worker.js';

if (isMainThread) {
/**
Expand All @@ -35,13 +35,5 @@ if (isMainThread) {
}

context.setContext({ workDir, shouldUseTypeScriptParserForJS, sonarlint, debugMemory, bundles });

server
.start(
Number.parseInt(port),
host,
createWorker(new URL(import.meta.url), getContext()),
600000000,
)
.catch(() => {});
server.start(Number.parseInt(port), host, createWorker(new URL(import.meta.url), getContext()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class BundleImpl implements Bundle {

// this archive is created in the bridge module
private static final String BUNDLE_LOCATION = "/sonarjs-1.0.0.tgz";
private static final String DEFAULT_STARTUP_SCRIPT = "package/bin/server.mjs";
private static final String DEFAULT_STARTUP_SCRIPT = "package/bin/server.cjs";
private Path deployLocation;
private final String bundleLocation;

Expand Down
6 changes: 3 additions & 3 deletions sonar-plugin/sonar-javascript-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,14 @@
<configuration>
<rules>
<requireFilesSize>
<minsize>80000000</minsize>
<minsize>70000000</minsize>
<maxsize>90000000</maxsize>
<files>
<file>${project.build.directory}/${project.build.finalName}-multi.jar</file>
</files>
</requireFilesSize>
<requireFilesSize>
<minsize>30000000</minsize>
<minsize>25000000</minsize>
<maxsize>55000000</maxsize>
<files>
<file>${project.build.directory}/${project.build.finalName}-linux-x64.jar</file>
Expand All @@ -378,7 +378,7 @@
</files>
</requireFilesSize>
<requireFilesSize>
<minsize>22500000</minsize>
<minsize>10000000</minsize>
<maxsize>27500000</maxsize>
<files>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
Expand Down

0 comments on commit 02e2a0c

Please sign in to comment.