Skip to content

Commit be0a9b0

Browse files
author
Daniel Del Core
committed
renames internal references to codeshift
1 parent 310b943 commit be0a9b0

File tree

7 files changed

+1762
-1424
lines changed

7 files changed

+1762
-1424
lines changed

packages/cli/src/index.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ program
8383
`
8484
Examples:
8585
# Run a transform for "@mylib/button" version 3.0.0 only
86-
$ codeshift --packages @mylib/button@3.0.0 /project/src
86+
$ hypermod --packages @mylib/button@3.0.0 /project/src
8787
8888
# Run all transforms for "@mylib/button" greater than version 3.0.0 and @mylib/range greater than 4.0.0
89-
$ codeshift --sequence --packages @mylib/button@3.0.0,@mylib/range@4.0.0 /project/src
89+
$ hypermod --sequence --packages @mylib/button@3.0.0,@mylib/range@4.0.0 /project/src
9090
9191
# Run the "my-custom-transform" transform
92-
$ codeshift -t path/to/my-custom-transform /project/src
92+
$ hypermod -t path/to/my-custom-transform /project/src
9393
94-
# Display a prompt with a list of codemods from my local \`codeshift.config.js\` file(s).
95-
$ codeshift /project/src`,
94+
# Display a prompt with a list of codemods from my local \`hypermod.config.js\` file(s).
95+
$ hypermod /project/src`,
9696
)
9797
.action((path, options) => main(path, options));
9898

@@ -105,15 +105,15 @@ program
105105
`
106106
Examples:
107107
# Print a list of available codemods for a single package
108-
$ codeshift list mylib
108+
$ hypermod list mylib
109109
110110
# Print a list of available codemods for multiple packages
111-
$ codeshift list @atlaskit/avatar @emotion/monorepo`,
111+
$ hypermod list @atlaskit/avatar @emotion/monorepo`,
112112
);
113113

114114
program
115115
.command('init [path]')
116-
.description('creates a new codeshift package')
116+
.description('creates a new hypermod package')
117117
.option('-c, --config-only', 'Output only a configuration file')
118118
.option('-t, --transform <value>', 'Transform version')
119119
.option('-p, --preset <value>', 'Preset transfrom')
@@ -124,32 +124,32 @@ program
124124
'after',
125125
`
126126
Examples:
127-
# Initializes an empty codeshift package at the current directory
128-
$ codeshift init --transform 10.0.0 my-codemod-package
127+
# Initializes an empty hypermod package at the current directory
128+
$ hypermod init --transform 10.0.0 my-codemod-package
129129
130-
# Initializes an empty codeshift package at the current directory
131-
$ codeshift init --transform 10.0.0 .
130+
# Initializes an empty hypermod package at the current directory
131+
$ hypermod init --transform 10.0.0 .
132132
133-
# Initializes a new codeshift package with a transform for 10.0.0 at the foobar dir
134-
$ codeshift init --transform 10.0.0 ~/foobar
133+
# Initializes a new hypermod package with a transform for 10.0.0 at the foobar dir
134+
$ hypermod init --transform 10.0.0 ~/foobar
135135
136-
# Initializes a new codeshift package with a preset "update-imports"
137-
$ codeshift init --package-name foobar --preset update-imports foobar
136+
# Initializes a new hypermod package with a preset "update-imports"
137+
$ hypermod init --package-name foobar --preset update-imports foobar
138138
139139
# Initializes a configuration file only
140-
$ codeshift init --config-only --preset update-imports path/to/src`,
140+
$ hypermod init --config-only --preset update-imports path/to/src`,
141141
);
142142

143143
program
144144
.command('validate [path]')
145-
.description('validates if a codeshift package is publishable')
145+
.description('validates if a hypermod package is publishable')
146146
.action(path => validate(path))
147147
.addHelpText(
148148
'after',
149149
`
150150
Examples:
151-
$ codeshift validate
152-
$ codeshift validate ./codemods/my-codemods`,
151+
$ hypermod validate
152+
$ hypermod validate ./codemods/my-codemods`,
153153
);
154154

155155
(async function () {

packages/cli/src/list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import chalk from 'chalk';
22
import { PluginManager } from 'live-plugin-manager';
33

44
import { fetchPackages } from './utils/fetch-package';
5-
import { getCodeshiftPackageName } from './utils/package-names';
5+
import { getHypermodPackageName } from './utils/package-names';
66

77
export default async function list(packages: string[]) {
88
const packageManager = new PluginManager();
@@ -16,7 +16,7 @@ export default async function list(packages: string[]) {
1616
);
1717
community &&
1818
configs.push({
19-
packageName: getCodeshiftPackageName(packageName),
19+
packageName: getHypermodPackageName(packageName),
2020
config: community.config,
2121
});
2222
remote && configs.push({ packageName, config: remote.config });

packages/cli/src/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ export default async function main(
126126
* Otherwise, locate any config files in parent directories
127127
*/
128128
const configFilePath = await findUp([
129+
'hypermod.config.js',
130+
'hypermod.config.ts',
131+
'hypermod.config.tsx',
132+
'src/hypermod.config.js',
133+
'src/hypermod.config.ts',
134+
'src/hypermod.config.tsx',
135+
'codemods/hypermod.config.js',
136+
'codemods/hypermod.config.ts',
137+
'codemods/hypermod.config.tsx',
129138
'codeshift.config.js',
130139
'codeshift.config.ts',
131140
'codeshift.config.tsx',
@@ -144,7 +153,7 @@ export default async function main(
144153
}
145154

146155
console.log(
147-
chalk.green('Found local codeshift.config file at:'),
156+
chalk.green('Found local hypermod.config file at:'),
148157
configFilePath,
149158
);
150159

packages/cli/src/utils/fetch-package.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,36 @@ import {
99
} from '@hypermod/fetcher';
1010
import { isValidConfig } from '@hypermod/validator';
1111

12-
import { getCodeshiftPackageName } from './package-names';
12+
import { getHypermodPackageName } from './package-names';
1313

1414
export async function fetchPackages(
1515
packageName: string,
1616
packageManager: PluginManager,
1717
) {
18-
const codeshiftPackageName = getCodeshiftPackageName(packageName);
19-
let codeshiftPackage: ConfigMeta | undefined;
18+
const hypermodPackageName = getHypermodPackageName(packageName);
19+
let hypermodPackage: ConfigMeta | undefined;
2020
let remotePackage: ConfigMeta | undefined;
2121

2222
const spinner = ora(
23-
`${chalk.green(
24-
'Attempting to download CodeshiftCommunity package:',
25-
)} ${packageName}`,
23+
`${chalk.green('Attempting to download Hypermod package:')} ${packageName}`,
2624
).start();
2725

2826
try {
29-
codeshiftPackage = await fetchPackage(codeshiftPackageName, packageManager);
27+
hypermodPackage = await fetchPackage(hypermodPackageName, packageManager);
3028
spinner.succeed(
31-
`${chalk.green(
32-
'Found CodeshiftCommunity package:',
33-
)} ${codeshiftPackageName}`,
29+
`${chalk.green('Found Hypermod package:')} ${hypermodPackageName}`,
3430
);
3531
} catch (error) {
3632
spinner.warn(
3733
`${chalk.yellow(
38-
`Unable to locate CodeshiftCommunity package:`,
39-
)} ${codeshiftPackageName}`,
34+
`Unable to locate Hypermod package:`,
35+
)} ${hypermodPackageName}`,
4036
);
4137
}
4238

43-
if (codeshiftPackage && !isValidConfig(codeshiftPackage.config)) {
39+
if (hypermodPackage && !isValidConfig(hypermodPackage.config)) {
4440
throw new Error(
45-
`Unable to locate a valid codeshift.config for Community package: ${packageName}`,
41+
`Unable to locate a valid hypermod.config for Community package: ${packageName}`,
4642
);
4743
}
4844

@@ -52,29 +48,31 @@ export async function fetchPackages(
5248
);
5349
remotePackage = await fetchRemotePackage(packageName, packageManager);
5450
spinner.succeed(
55-
`${chalk.green('Found codeshift package:')} ${packageName}`,
51+
`${chalk.green('Found remote Hypermod package:')} ${packageName}`,
5652
);
5753
} catch (error) {
5854
spinner.warn(
59-
`${chalk.yellow('Unable to locate codeshift package:')} ${packageName}`,
55+
`${chalk.yellow(
56+
'Unable to locate remote Hypermod package:',
57+
)} ${packageName}`,
6058
);
6159
}
6260

6361
if (remotePackage && !isValidConfig(remotePackage.config)) {
6462
throw new Error(
65-
`Unable to locate a valid codeshift.config for remote package: ${packageName}`,
63+
`Unable to locate a valid hypermod.config for remote package: ${packageName}`,
6664
);
6765
}
6866

69-
if (!codeshiftPackage && !remotePackage) {
67+
if (!hypermodPackage && !remotePackage) {
7068
throw new Error(
71-
`Unable to locate package from codeshift-community or NPM.
69+
`Unable to locate package from Hypermod Community or NPM.
7270
Make sure the package name "${packageName}" is correct and try again.`,
7371
);
7472
}
7573

7674
return {
77-
community: codeshiftPackage,
75+
community: hypermodPackage,
7876
remote: remotePackage,
7977
};
8078
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export function getCodeshiftPackageName(packageName: string) {
1+
export function getHypermodPackageName(packageName: string) {
22
return `@hypermod/mod-${packageName.replace('@', '').replace('/', '__')}`;
33
}

packages/fetcher/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export async function fetchRemotePackage(
9595
packageName: string,
9696
packageManager: PluginManager,
9797
): Promise<ConfigMeta> {
98+
if (['javascript', 'typescript'].includes(packageName)) {
99+
throw new Error(`'${packageName}' is ignored as a remote package.`);
100+
}
101+
98102
await packageManager.install(packageName);
99103
const info = packageManager.getInfo(packageName);
100104

0 commit comments

Comments
 (0)