Skip to content

Commit

Permalink
Merge pull request #20 from ag-grid/develop
Browse files Browse the repository at this point in the history
Release CLI v31.2.0
  • Loading branch information
timkendrick authored Mar 20, 2024
2 parents b720ae7 + 132c388 commit 948c75d
Show file tree
Hide file tree
Showing 141 changed files with 1,030 additions and 680 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules/
/packages/*/node_modules/
/packages/*/vitest.config.mts.timestamp-*.mjs
/coverage/
/docs/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ The following packages contain internal library helpers:

- [`ast`](./packages/ast/): AST transformation tools
- [`codemod-utils`](./packages/codemod-utils/): Codemod utility helpers
- [`codemod-task-utils`](./packages/codemod-task-utils/): Codemod task runner helpers
- [`systemjs-plugin`](./packages/systemjs-plugin/): SystemJS plugin for TypeScript/JSX/CSS source files
- [`test-utils`](./packages/test-utils/): Automated testing helpers
- [`worker-utils`](./packages/worker-utils/): Worker utility helpers
- [`types`](./packages/types/): Shared type definitions

The following packages contain configuration shared across multiple internal packages:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "vitest run",
"test:watch": "vitest watch",
"coverage": "vitest run --coverage",
"coverage:report": "vitest run --coverage --config ./report.vitest.config.ts",
"coverage:report": "vitest run --coverage --config ./report.vitest.config.mts",
"clean": "rm -rf docs coverages packages/*/dist",
"version": "pnpm --filter @ag-grid-community/cli exec -- pnpm run --silent version",
"publish": "pnpm run --filter @ag-grid-community/cli publish"
Expand Down
2 changes: 1 addition & 1 deletion packages/ast/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../build-config/templates/tsc/tsconfig.json",
"include": ["src", "lib.ts", "lib.test.ts", "*.config.ts", "package.json"]
"include": ["src", "lib.ts", "lib.test.ts", "*.config.mts", "package.json"]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { join, resolve } from 'path';
import { defineConfig, mergeConfig } from 'vite';

import base from './vite.config';
import base from './vite.config.mts';

export default mergeConfig(
base,
Expand Down
2 changes: 1 addition & 1 deletion packages/build-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"lint": "eslint --ext js,cjs,mjs,ts ."
},
"dependencies": {
"@types/node": "20.5.9",
"@types/node": "20.11.29",
"@types/react": "18.2.21",
"@typescript-eslint/eslint-plugin": "6.6.0",
"@typescript-eslint/parser": "6.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/build-config/templates/vite/lib.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default mergeConfig(
defineConfig({
plugins: [
dts({
exclude: ['node_modules/**', '*.config.ts', '**/*.test.ts'],
exclude: ['node_modules/**', '*.config.mts', '**/*.test.ts'],
}),
],
}),
Expand Down
3 changes: 0 additions & 3 deletions packages/build-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
"task": "./scripts/task.cjs",
"lint": "eslint --ext cjs ."
},
"dependencies": {
"ts-node": "^10"
},
"devDependencies": {
"@ag-grid-devtools/build-config": "workspace:*"
}
Expand Down
57 changes: 55 additions & 2 deletions packages/build-tools/src/prompt.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { clearScreenDown, moveCursor } from 'node:readline';
import readline from 'node:readline/promises';
import { parseArgs } from 'node:util';
import { gray, green, red } from './cli.mjs';
Expand Down Expand Up @@ -30,6 +31,7 @@ export function createPrompt(variables) {
const {
prompt: promptLabel = label,
value: optionsValue,
options: choices,
default: defaultValue = null,
parse = String,
format = JSON.stringify,
Expand All @@ -50,7 +52,7 @@ export function createPrompt(variables) {
return existingValue;
} else {
const answer = defaultValue;
return parse(await readline(question, answer));
return parse(await readline(question, answer, choices));
}
})();
const error = validate ? validate(value, values, env) : null;
Expand Down Expand Up @@ -86,12 +88,63 @@ export function createPrompt(variables) {
}

export function createPromptReader({ input, output }) {
return (line, defaultValue) => {
return (line, defaultValue, options) => {
const rl = readline.createInterface({ input, output });
const response = rl.question(`${line} `);
if (options && options.length > 0) {
const defaultOptionIndex = defaultValue != null ? options.indexOf(defaultValue) : -1;
let selectedOptionIndex = defaultOptionIndex !== -1 ? defaultOptionIndex : null;
listOptions(rl, options, selectedOptionIndex);
rl.input.on('keypress', (char, key) => {
switch (key.name) {
case 'tab':
case 'down': {
selectedOptionIndex = ((selectedOptionIndex ?? -1) + 1) % options.length;
changeSelectedIndex(rl, options, selectedOptionIndex);
break;
}
case 'up': {
selectedOptionIndex =
(options.length + (selectedOptionIndex ?? 0) - 1) % options.length;
changeSelectedIndex(rl, options, selectedOptionIndex);
break;
}
case 'return': {
clearScreenDown(rl.output);
break;
}
default: {
selectedOptionIndex = null;
}
}
});
function changeSelectedIndex(rl, options, selectedOptionIndex) {
clearInput(rl);
listOptions(rl, options, selectedOptionIndex);
rl.write(options[selectedOptionIndex]);
}
}
if (defaultValue != null) rl.write(defaultValue);
return response.finally(() => rl.close());
};

function clearInput(rl) {
rl.write(null, { ctrl: true, name: 'u' });
}

function listOptions(rl, options, selectedIndex) {
rl.pause();
const inputCursorPos = rl.getCursorPos();
const formattedOptions = options.map((value, index) => {
const isSelected = index === selectedIndex;
const message = `${isSelected ? '◉' : '◯'} ${value}`;
return isSelected ? green(message) : message;
});
const outputLines = ['', ...formattedOptions, ''];
rl.output.write(outputLines.join('\n'));
moveCursor(rl.input, inputCursorPos.cols, -(outputLines.length - 1));
rl.resume();
}
}

export function createPromptWriter(output) {
Expand Down
7 changes: 7 additions & 0 deletions packages/build-tools/src/validate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ export function validateOneOf(options) {
};
}

export function validateOptional(validator) {
return function validateOptional(value) {
if (value === null) return null;
return validator(value);
};
}

function getPathStats(path) {
try {
return statSync(path);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'path';
import { defineConfig, mergeConfig } from 'vite';

import base from '../codemods/vite.config';
import base from '../codemods/vite.config.mts';

import pkg from '../codemods/package.json' assert { type: 'json' };

Expand Down
6 changes: 4 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@ag-grid-community/cli",
"version": "31.1.0",
"version": "31.2.0",
"license": "MIT",
"description": "AG Grid developer toolkit",
"author": "AG Grid <[email protected]>",
Expand All @@ -21,7 +21,7 @@
"build:readme": "cp README.md dist/README.md",
"build:pkg": "pnpm run --filter build-tools pkg $PWD $PWD/dist/package.json",
"build:codemods": "pnpm run build:codemods:lib && pnpm run build:codemods:pkg",
"build:codemods:lib": "vite build --config codemods.vite.config.js",
"build:codemods:lib": "vite build --config codemods.vite.config.mts",
"build:codemods:pkg": "pnpm run --filter build-tools pkg $PWD/../codemods $PWD/dist/node_modules/@ag-grid-community/codemods/package.json",
"lint": "pnpm run '/^lint:.*/'",
"lint:eslint": "eslint --ext js,cjs,mjs,ts .",
Expand All @@ -43,11 +43,13 @@
},
"devDependencies": {
"@ag-grid-devtools/build-config": "workspace:*",
"@ag-grid-devtools/codemod-task-utils": "workspace:*",
"@ag-grid-devtools/types": "workspace:*",
"@ag-grid-devtools/utils": "workspace:*",
"@ag-grid-devtools/worker-utils": "workspace:*",
"@types/diff": "5.0.8",
"@types/graceful-fs": "4.1.9",
"@types/node": "20.11.29",
"@types/semver": "7.5.6",
"diff": "5.1.0",
"graceful-fs": "4.2.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import codemods from '@ag-grid-community/codemods';
import { createCodemodTask } from '@ag-grid-devtools/codemod-task-utils';
import {
Codemod,
CodemodTaskInput,
Expand All @@ -22,7 +23,6 @@ import { getCliCommand } from '../utils/pkg';
import { green, indentErrorMessage, log } from '../utils/stdio';
import { Worker, WorkerTaskQueue } from '../utils/worker';
import { requireDynamicModule, resolveDynamicModule } from '../utils/module';
import { createCodemodTask } from '../../../codemod-utils/src/taskHelpers';

const { versions } = codemods;

Expand Down
8 changes: 1 addition & 7 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
"extends": "../build-config/templates/tsc/tsconfig.json",
"include": [
"src",
"index.ts",
"*.config.ts",
"package.json",
"../codemod-utils/src/taskHelpers.ts"
]
"include": ["src", "index.ts", "*.config.mts", "package.json"]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { join, resolve } from 'path';
import { defineConfig, mergeConfig } from 'vite';

import base from './vite.config';
import base from './vite.config.mts';

export default mergeConfig(
base,
Expand Down
2 changes: 2 additions & 0 deletions packages/codemod-task-utils/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist/
/vitest.config.ts.timestamp-*.mjs
1 change: 1 addition & 0 deletions packages/codemod-task-utils/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@ag-grid-devtools/build-config/templates/eslint/lib.eslintrc.cjs');
1 change: 1 addition & 0 deletions packages/codemod-task-utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist/
10 changes: 10 additions & 0 deletions packages/codemod-task-utils/lib.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from 'vitest';

import * as lib from './lib';

test('module exports', () => {
expect({ ...lib }).toEqual({
createCodemodTask: lib.createCodemodTask,
initCodemodTaskWorker: lib.initCodemodTaskWorker,
});
});
2 changes: 2 additions & 0 deletions packages/codemod-task-utils/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './src/task';
export * from './src/worker';
57 changes: 57 additions & 0 deletions packages/codemod-task-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"private": true,
"name": "@ag-grid-devtools/codemod-task-utils",
"version": "0.0.1",
"license": "MIT",
"description": "Codemod task runner helpers",
"author": "AG Grid <[email protected]>",
"homepage": "https://www.ag-grid.com/",
"repository": {
"type": "git",
"url": "https://github.com/ag-grid/devtools.git"
},
"bugs": {
"url": "https://github.com/ag-grid/devtools/issues"
},
"type": "module",
"main": "./lib.ts",
"module": "./lib.ts",
"scripts": {
"build": "pnpm run build:lib && pnpm run build:docs && pnpm run build:pkg",
"build:lib": "vite build",
"build:docs": "typedoc",
"build:pkg": "pnpm run --filter build-tools pkg $PWD $PWD/dist/package.json",
"lint": "pnpm run '/^lint:.*/'",
"lint:eslint": "eslint --ext js,cjs,mjs,ts .",
"lint:typescript": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest watch",
"update-event-keys": "./scripts/update-event-keys ./src/eventKeys.ts"
},
"pkg": {
"type": "module",
"main": "./lib/lib.cjs",
"module": "/lib/lib.js",
"types": "./lib.d.ts",
"exports": {
".": {
"import": "./lib/lib.js",
"require": "./lib/lib.cjs"
}
}
},
"dependencies": {
"@ag-grid-devtools/types": "workspace:*",
"@ag-grid-devtools/worker-utils": "workspace:*"
},
"devDependencies": {
"@ag-grid-devtools/build-config": "workspace:*"
},
"peerDependencies": {
"eslint": "^8",
"typedoc": "^0.25",
"typescript": "^5",
"vite": "^5",
"vitest": "^1"
}
}
1 change: 1 addition & 0 deletions packages/codemod-task-utils/prettier.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@ag-grid-devtools/build-config/templates/prettier/prettier.config.mjs';
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type CodemodTask, type CodemodTaskInput, type FsUtils } from '@ag-grid-devtools/types';
import { configureWorkerTask, initTaskWorker } from './worker';
import { configureWorkerTask, initTaskWorker } from '@ag-grid-devtools/worker-utils';

export function initCodemodTaskWorker(
task: CodemodTask,
Expand Down
4 changes: 4 additions & 0 deletions packages/codemod-task-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../build-config/templates/tsc/tsconfig.json",
"include": ["src", "lib.ts", "lib.test.ts", "*.config.mts", "package.json"]
}
5 changes: 5 additions & 0 deletions packages/codemod-task-utils/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": ["../build-config/templates/typedoc/base.typedoc.json"],
"entryPoints": ["lib.ts"],
"out": "./dist/docs"
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { join, resolve } from 'path';
import { defineConfig, mergeConfig } from 'vite';

import base from './vite.config';
import base from './vite.config.mts';

export default mergeConfig(
base,
Expand Down
1 change: 0 additions & 1 deletion packages/codemod-utils/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ test('module exports', () => {
VueTemplateFormatter: lib.VueTemplateFormatter,
createAngularBooleanLiteral: lib.createAngularBooleanLiteral,
createBabelPlugin: lib.createBabelPlugin,
createCodemodTask: lib.createCodemodTask,
createVueAstNode: lib.createVueAstNode,
createVueBooleanLiteral: lib.createVueBooleanLiteral,
createVueExpressionContainer: lib.createVueExpressionContainer,
Expand Down
1 change: 0 additions & 1 deletion packages/codemod-utils/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from './src/angularHelpers';
export * from './src/babelHelpers';
export * from './src/plugins';
export * from './src/prettierHelpers';
export * from './src/taskHelpers';
export * from './src/templateHelpers';
export * from './src/transformer';
export * from './src/vueHelpers';
10 changes: 1 addition & 9 deletions packages/codemod-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
{
"extends": "../build-config/templates/tsc/tsconfig.json",
"include": [
"src",
"lib.ts",
"lib.test.ts",
"*.config.ts",
"package.json",
"lib.test.ts",
"lib.ts"
]
"include": ["src", "lib.ts", "lib.test.ts", "*.config.mts", "package.json"]
}
Loading

0 comments on commit 948c75d

Please sign in to comment.