Skip to content

Commit

Permalink
chore: cleanup code-mods
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkdev98 committed Jul 31, 2023
1 parent 28fcb18 commit c80410c
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 646 deletions.
73 changes: 1 addition & 72 deletions packages/cli/src/code-mod/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { cpus } from "node:os";
import { executeApiClientToExperimentalCodeGen } from "./mods/api-client-to-experimental-code-gen.js";
import { executeLintConfigToEslintPlugin } from "./mods/lint-config-to-eslint-plugin.js";
import { executeUpdateQueriesSignatureChange } from "./mods/update-queries-signature-change.js";

export const PARALLEL_COUNT = Math.max(cpus().length - 1, 1);

Expand All @@ -11,72 +8,4 @@ export const PARALLEL_COUNT = Math.max(cpus().length - 1, 1);
* exec: (logger: Logger) => Promise<void>
* }>}
*/
export const codeModMap = {
"update-queries-signature-change": {
description: `Convert arguments in call sites of generated 'queries.entityUpdate' to pass in the named 'where' and 'update' parameters.
It also adds 'returning: "*"' if it detects that the result is used, or if it is unable to detect that the return value is unused.
Inline update & where;
// old
await queries.entityUpdate(sql, { /* inline update */ }, { /* inline where */});
// new
await queries.entityUpdate(sql, {
update: { /* inline update */ },
where: { /* inline where */ },
});
Referenced update & where:
// old
await queries.entityUpdate(sql, update, where);
// new
await queries.entityUpdate(sql, {
update,
where,
});
Infer that result is used:
// old
const [updatedEntity] = await queries.entityUpdate(sql, update, where);
// new
const [updatedEntity] = await queries.entityUpdate(sql, {
update,
where,
returning: "*",
});
Or any combination of the above.
`,
exec: executeUpdateQueriesSignatureChange,
},
"lint-config-to-eslint-plugin": {
description: `Convert all known usages of @compas/lint-config to use @compas/eslint-plugin.
This only updates the configuration files and does not update the code to be consistent with the newly enforced rules.
`,
exec: executeLintConfigToEslintPlugin,
},
"api-client-to-experimental-code-gen": {
description: `Convert the project to use experimental code-gen based on a list of structures in '$project/structures.txt'.
'structures.txt' has the following format;
https://a.remote.compas.backend -- src/generated
./local-openapi.json -- src/generated/foo -- defaultGroup
The code-mode executes the following steps:
- Resolve and validated 'structures.txt'
- Resolve all mentioned structures from 'structures.txt'
- Overwrite 'scripts/generate.mjs'
- Execute 'scripts/generate.mjs'
- Try to overwrite as much type usages as possible based on the cleaner type name generation.
Manual cleanup:
- Remove structures.txt
- Copy-edit & cleanup 'scripts/generate.mjs'
- Use environment variables where appropriate
- Cleanup imports
- Correct 'targetRuntime' when using React-native.
- Go through 'mutation' hooks usage & flatten arguments
`,
exec: executeApiClientToExperimentalCodeGen,
},
};
export const codeModMap = {};

This file was deleted.

213 changes: 0 additions & 213 deletions packages/cli/src/code-mod/mods/api-client-to-experimental-code-gen.js

This file was deleted.

This file was deleted.

47 changes: 0 additions & 47 deletions packages/cli/src/code-mod/mods/lint-config-to-eslint-plugin.js

This file was deleted.

This file was deleted.

Loading

0 comments on commit c80410c

Please sign in to comment.