Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
chore: renamed intuita to codemod.com in all applicable places wherev…
Browse files Browse the repository at this point in the history
…er possible (#190)
  • Loading branch information
grzpab authored Jan 29, 2024
1 parent 386df3d commit 5cb28e4
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 83 deletions.
6 changes: 3 additions & 3 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Intuita's Codemod Engine Node
# Codemod.com's Codemod Engine Node

## Installation

Expand All @@ -16,8 +16,8 @@ Install the Codemod Engine Node as the global executable sourced from the projec

Install the Codemod Engine Node as the global executable sourced from the NPM Registry https://www.npmjs.com/.

pnpm i -g intuita
pnpm i -g codemod

## Execution

pnpx intuita [framework/version/codemod-name]
pnpx codemod [framework/version/codemod-name]
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
# Intuita's Codemod Engine Node
# Codemod.com's Codemod Engine Node

Intuita gives you multiple ways to discover, run & share supported codemods and code automation recipes.
Codemod.com gives you multiple ways to discover, run & share supported codemods and code automation recipes.

![Running Intuita CLI](https://raw.githubusercontent.com/intuita-inc/intuita-website/main/theme/assets/images/hero-video.gif)
![Running Codemod CLI](https://raw.githubusercontent.com/codemod-com/website/main/theme/assets/images/hero-video.gif)

## Installation

npm i intuita
npm i codemod

## Global installation (recommended)

npm i -g intuita
npm i -g codemod

## Usage

### Running a codemod

intuita [framework/version/codemod-name]
codemod [framework/version/codemod-name]

#### Example (running Next.js app router receipe codemod)

intuita next/13/app-router-recipe
codemod next/13/app-router-recipe

### List available codemods

The `list` command can be used to list all codemods available in the [Codemod Registry](https://github.com/intuita-inc/codemod-registry).
The `list` command can be used to list all codemods available in the [Codemod Registry](https://github.com/codemod-com/codemod-registry).

intuita list
codemod list

### Sync registry

The `syncRegistry` command can be used to sync local codemods with the public [Codemod Registry](https://github.com/intuita-inc/codemod-registry).
The `syncRegistry` command can be used to sync local codemods with the public [Codemod Registry](https://github.com/codemod-com/codemod-registry).

intuita syncRegistry
codemod syncRegistry

### Generate codemod from file diff

The `learn` command can be used to send the diff of the latest edited file to the Codemod Studio and have it automatically build an explainable and debuggable codemod.

After running this command, if any git diff exists, Intuita will use the diff as before/after snippets in the [Codemod Studio](https://codemod.studio).
After running this command, if any git diff exists, `codemod` will use the diff as before/after snippets in the [Codemod Studio](https://codemod.studio).

intuita learn
codemod learn

### Options

- [`--include`](https://docs.intuita.io/docs/cli/advanced-usage#--include)
- [`--exclude`](https://docs.intuita.io/docs/cli/advanced-usage#--exclude)
- [`--targetPath`](https://docs.intuita.io/docs/cli/advanced-usage#--targetpath)
- [`--sourcePath`](https://docs.intuita.io/docs/cli/advanced-usage#--sourcepath)
- [`--codemodEngine`](https://docs.intuita.io/docs/cli/advanced-usage#--codemodengine)
- [`--fileLimit`](https://docs.intuita.io/docs/cli/advanced-usage#--filelimit)
- [`--usePrettier`](https://docs.intuita.io/docs/cli/advanced-usage#--useprettier)
- [`--useCache`](https://docs.intuita.io/docs/cli/advanced-usage#--usecache)
- [`--useJson`](https://docs.intuita.io/docs/cli/advanced-usage#--usejson)
- [`--threadCount`](https://docs.intuita.io/docs/cli/advanced-usage#--threadcount)
- [`--dryRun`](https://docs.intuita.io/docs/cli/advanced-usage#--dryrun)
- [`--telemetryDisable`](https://docs.intuita.io/docs/cli/advanced-usage#--telemetrydisable)
- [`--include`](https://docs.codemod.com/docs/cli/advanced-usage#--include)
- [`--exclude`](https://docs.codemod.com/docs/cli/advanced-usage#--exclude)
- [`--targetPath`](https://docs.codemod.com/docs/cli/advanced-usage#--targetpath)
- [`--sourcePath`](https://docs.codemod.com/docs/cli/advanced-usage#--sourcepath)
- [`--codemodEngine`](https://docs.codemod.com/docs/cli/advanced-usage#--codemodengine)
- [`--fileLimit`](https://docs.codemod.com/docs/cli/advanced-usage#--filelimit)
- [`--usePrettier`](https://docs.codemod.com/docs/cli/advanced-usage#--useprettier)
- [`--useCache`](https://docs.codemod.com/docs/cli/advanced-usage#--usecache)
- [`--useJson`](https://docs.codemod.com/docs/cli/advanced-usage#--usejson)
- [`--threadCount`](https://docs.codemod.com/docs/cli/advanced-usage#--threadcount)
- [`--dryRun`](https://docs.codemod.com/docs/cli/advanced-usage#--dryrun)
- [`--telemetryDisable`](https://docs.codemod.com/docs/cli/advanced-usage#--telemetrydisable)

## Contribution

We'd love for you to contribute to the [Codemod Engine](https://github.com/intuita-inc/codemod-engine-node) and the [Codemod Registry](https://github.com/intuita-inc/codemod-registry). Please note that once you create a pull request, you will be asked to sign our [Contributor License Agreement](https://cla-assistant.io/intuita-inc/codemod-registry).
We'd love for you to contribute to the [Codemod Engine](https://github.com/codemod-com/codemod-engine-node) and the [Codemod Registry](https://github.com/codemod-com/codemod-registry). Please note that once you create a pull request, you will be asked to sign our [Contributor License Agreement](https://cla-assistant.io/codemod-com/codemod-registry).

We're always excited to support codemods for more frameworks and libraries. Contributing allows us to make codemods more accessible to more framework builders, developers, and more.

## Telemetry 🔭

We collect anonymous usage data to improve our product. Collected data cannot be linked to individual users. We do not store personal data/code.

For more details and samples of collected data see our [telemetry compliance considerations](https://docs.intuita.io/docs/about-intuita/legal/telemetry-compliance) doc.
For more details and samples of collected data see our [telemetry compliance considerations](https://docs.codemod.com/docs/about/telemetry-compliance) doc.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "intuita",
"version": "0.7.3",
"name": "codemod",
"version": "0.8.0",
"description": "A codemod engine for Node.js libraries (jscodeshift, ts-morph, etc.)",
"type": "module",
"exports": null,
"repository": {
"type": "git",
"url": "https://github.com/intuita-inc/codemod-engine-node"
"url": "https://github.com/codemod-com/codemod-engine-node"
},
"keywords": [
"codemod",
Expand Down Expand Up @@ -82,7 +82,7 @@
},
"packageManager": "[email protected]",
"scripts": {
"build": "esbuild ./src/index.ts --define:__INTUITA_CLI_VERSION__=\\\"0.7.3\\\" --bundle --platform=node --target=node16 --minify --format=cjs --legal-comments=inline --outfile=./dist/index.cjs",
"build": "esbuild ./src/index.ts --define:__CODEMODCOM_CLI_VERSION__=\\\"0.8.0\\\" --bundle --platform=node --target=node16 --minify --format=cjs --legal-comments=inline --outfile=./dist/index.cjs",
"lint:eslint": "eslint src --fix --ext ts",
"lint:prettier": "prettier --write .",
"package": "pkg --compress GZip .",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Axios from 'axios';
import { type Input, parse, object, string, nullable } from 'valibot';
import type FormData from 'form-data';

const X_INTUITA_ACCESS_TOKEN = 'X-Intuita-Access-Token'.toLocaleLowerCase();
const X_CODEMODCOM_ACCESS_TOKEN = 'X-Intuita-Access-Token'.toLocaleLowerCase();

const dataSchema = object({
username: nullable(string()),
Expand All @@ -18,7 +18,7 @@ export const validateAccessToken = async (
{},
{
headers: {
[X_INTUITA_ACCESS_TOKEN]: accessToken,
[X_CODEMODCOM_ACCESS_TOKEN]: accessToken,
},
timeout: 5000,
},
Expand All @@ -33,7 +33,7 @@ export const publish = async (
): Promise<void> => {
await Axios.post('https://telemetry.intuita.io/publish', formData, {
headers: {
[X_INTUITA_ACCESS_TOKEN]: accessToken,
[X_CODEMODCOM_ACCESS_TOKEN]: accessToken,
'Content-Type': 'multipart/form-data',
},
timeout: 10000,
Expand All @@ -42,7 +42,7 @@ export const publish = async (

export const revokeCLIToken = async (token: string): Promise<void> => {
await Axios.delete('https://telemetry.intuita.io/revokeToken', {
headers: { [X_INTUITA_ACCESS_TOKEN]: token },
headers: { [X_CODEMODCOM_ACCESS_TOKEN]: token },
timeout: 10000,
});
};
12 changes: 6 additions & 6 deletions src/consoleOverride.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
export const CONSOLE_OVERRIDE = `
console.debug = (data, ...args) => {
__INTUITA__console__('debug', data, ...args);
__CODEMODCOM__console__('debug', data, ...args);
};
console.error = (data, ...args) => {
__INTUITA__console__('error', data, ...args);
__CODEMODCOM__console__('error', data, ...args);
};
console.log = (data, ...args) => {
__INTUITA__console__('log', data, ...args);
__CODEMODCOM__console__('log', data, ...args);
};
console.info = (data, ...args) => {
__INTUITA__console__('info', data, ...args);
__CODEMODCOM__console__('info', data, ...args);
};
console.trace = (data, ...args) => {
__INTUITA__console__('trace', data, ...args);
__CODEMODCOM__console__('trace', data, ...args);
};
console.warn = (data, ...args) => {
__INTUITA__console__('warn', data, ...args);
__CODEMODCOM__console__('warn', data, ...args);
};
`;
18 changes: 12 additions & 6 deletions src/downloadCodemod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type CodemodDownloaderBlueprint = Readonly<{
export class CodemodDownloader implements CodemodDownloaderBlueprint {
public constructor(
private readonly __printer: PrinterBlueprint,
private readonly __intuitaDirectoryPath: string,
private readonly __configurationDirectoryPath: string,
protected readonly _cacheUsed: boolean,
protected readonly _fileDownloadService: FileDownloadServiceBlueprint,
protected readonly _tarService: TarService,
Expand All @@ -34,10 +34,10 @@ export class CodemodDownloader implements CodemodDownloaderBlueprint {
public async syncRegistry() {
this.__printer.printConsoleMessage(
'info',
`Syncing the Codemod Registry into ${this.__intuitaDirectoryPath}`,
`Syncing the Codemod Registry into ${this.__configurationDirectoryPath}`,
);

await mkdir(this.__intuitaDirectoryPath, { recursive: true });
await mkdir(this.__configurationDirectoryPath, { recursive: true });

const getResponse = await Axios.get(
`${CODEMOD_REGISTRY_URL}/registry.tar.gz`,
Expand All @@ -48,7 +48,10 @@ export class CodemodDownloader implements CodemodDownloaderBlueprint {

const buffer = Buffer.from(getResponse.data);

await this._tarService.extract(this.__intuitaDirectoryPath, buffer);
await this._tarService.extract(
this.__configurationDirectoryPath,
buffer,
);
}

public async download(
Expand All @@ -61,14 +64,17 @@ export class CodemodDownloader implements CodemodDownloaderBlueprint {
}using cache`,
);

await mkdir(this.__intuitaDirectoryPath, { recursive: true });
await mkdir(this.__configurationDirectoryPath, { recursive: true });

// make the codemod directory
const hashDigest = createHash('ripemd160')
.update(name)
.digest('base64url');

const directoryPath = join(this.__intuitaDirectoryPath, hashDigest);
const directoryPath = join(
this.__configurationDirectoryPath,
hashDigest,
);

await mkdir(directoryPath, { recursive: true });

Expand Down
14 changes: 7 additions & 7 deletions src/executeMainThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { handlePublishCliCommand } from './handlePublishCliCommand.js';
import { handleLogoutCliCommand } from './handleLogoutCliCommand.js';

// the build script contains the version
declare const __INTUITA_CLI_VERSION__: string;
declare const __CODEMODCOM_CLI_VERSION__: string;

export const executeMainThread = async () => {
const slicedArgv = hideBin(process.argv);
Expand All @@ -54,7 +54,7 @@ export const executeMainThread = async () => {
process.stdin.unref();

const argvObject = yargs(slicedArgv)
.scriptName('intuita')
.scriptName('codemod')
.command('*', 'runs a codemod or recipe', (y) => buildOptions(y))
.command(
'runOnPreCommit [files...]',
Expand Down Expand Up @@ -94,15 +94,15 @@ export const executeMainThread = async () => {
(y) =>
buildUseJsonOption(y).option('token', {
type: 'string',
description: 'token required to sign in to the Intuita CLI',
description: 'token required to sign in to the Codemod CLI',
}),
)
.command('logout', 'logs out', (y) => buildUseJsonOption(y))
.command('publish', 'publish the codemod to Intuita Registry', (y) =>
.command('publish', 'publish the codemod to Codemod Registry', (y) =>
buildUseJsonOption(y),
)
.help()
.version(__INTUITA_CLI_VERSION__);
.version(__CODEMODCOM_CLI_VERSION__);

if (slicedArgv.length === 0) {
argvObject.showHelp();
Expand Down Expand Up @@ -318,7 +318,7 @@ export const executeMainThread = async () => {
return;
}

const intuitaDirectoryPath = join(
const configurationDirectoryPath = join(
String(argv._) === 'runOnPreCommit' ? process.cwd() : homedir(),
'.intuita',
);
Expand All @@ -337,7 +337,7 @@ export const executeMainThread = async () => {

const codemodDownloader = new CodemodDownloader(
printer,
intuitaDirectoryPath,
configurationDirectoryPath,
argv.useCache,
fileDownloadService,
tarService,
Expand Down
6 changes: 3 additions & 3 deletions src/handleListCliCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import * as v from 'valibot';
import type { PrinterBlueprint } from './printer.js';

export const handleListNamesCommand = async (printer: PrinterBlueprint) => {
const intuitaDirectoryPath = join(homedir(), '.intuita');
const configurationDirectoryPath = join(homedir(), '.intuita');

await mkdir(intuitaDirectoryPath, { recursive: true });
await mkdir(configurationDirectoryPath, { recursive: true });

const configFiles = await glob('**/config.json', {
absolute: true,
cwd: intuitaDirectoryPath,
cwd: configurationDirectoryPath,
fs,
onlyFiles: true,
});
Expand Down
2 changes: 1 addition & 1 deletion src/handleLoginCliCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ export const handleLoginCliCommand = async (

printer.printConsoleMessage(
'info',
'You are successfully logged in with the Intuita CLI!',
'You are successfully logged in with the Codemod CLI!',
);
};
Loading

0 comments on commit 5cb28e4

Please sign in to comment.