Skip to content

Commit 856e97f

Browse files
authored
Merge pull request #179 from chocolat-chaud-io/123-fix-rename-project
fix: rename project
2 parents e5bed26 + a2a21b3 commit 856e97f

File tree

8 files changed

+203
-103
lines changed

8 files changed

+203
-103
lines changed

apps/cli/src/commands/rename-project.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import fs from "fs"
22
import path from "path"
33

44
import { Command, Option } from "clipanion"
5+
import { camelCase, kebabCase } from "lodash"
56

67
import { walk } from "../utils"
78

89
export class RenameProject extends Command {
910
static paths = [["rename-project"]]
10-
organization = Option.String("--organization",{ required: true })
11+
organization = Option.String("--organization", { required: true })
1112
project = Option.String("--project", { required: true })
1213

1314
static usage = Command.Usage({
@@ -22,7 +23,6 @@ export class RenameProject extends Command {
2223

2324
async renameProject() {
2425
try {
25-
console.log(this.organization, this.project, __dirname)
2626
const organizationRegex = /^[a-zA-Z-\d_]+$/gim
2727
if (!organizationRegex.test(this.organization)) {
2828
console.error("The organization name must respect this regex /^[a-zA-Z-\\d_]+$/gmi")
@@ -37,6 +37,8 @@ export class RenameProject extends Command {
3737
const databaseName = this.project.replace(/-/g, "_")
3838
const databaseFiles = ["docker-compose.yml", "seed-data.js", "init.sql", "test.ts", "orm-config.ts"]
3939

40+
const camelCaseProjectName = camelCase(this.project)
41+
4042
const ignoredFolders = ["node_modules", "dist", ".git", ".idea", ".cache"]
4143
for await (const entry of walk(path.join(__dirname, "../"), ignoredFolders)) {
4244
const entryStat = await fs.promises.lstat(entry)
@@ -46,7 +48,7 @@ export class RenameProject extends Command {
4648
const isDatabaseFile = databaseFiles.some(databaseFile => entry.includes(databaseFile))
4749
const replacedFileContent = fileContent
4850
.replace(/chocolat-chaud-io/gim, this.organization)
49-
.replace(/stator/gim, isDatabaseFile ? databaseName : this.project)
51+
.replace(/stator/gim, isDatabaseFile ? databaseName : camelCaseProjectName)
5052
await fs.promises.writeFile(entry, replacedFileContent, "utf-8")
5153
}
5254
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { environment } from "../environments/environment"
44

55
export const apiTagTypes = { todo: "todo" }
66

7-
export const statorApi = createApi({
7+
export const api = createApi({
88
baseQuery: fetchBaseQuery({ baseUrl: environment.apiUrl.replace("/api", "") }),
99
tagTypes: Object.values(apiTagTypes),
1010
endpoints: () => ({}),

apps/webapp/src/redux/endpoints/todos-endpoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { statorApi as api } from "../stator-api"
1+
import { api } from "../api"
22
const injectedRtkApi = api.injectEndpoints({
33
endpoints: build => ({
44
getManyTodos: build.query<GetManyTodosApiResponse, GetManyTodosApiArg>({

apps/webapp/src/redux/store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { setupListeners } from "@reduxjs/toolkit/query"
33

44
import { addGeneratedCacheKeys } from "./endpoints/generated-cache-keys"
55
import { errorMiddleware } from "./middlewares/error-middleware"
6-
import { statorApi } from "./stator-api"
6+
import { api } from "./api"
77
import { snackbarThunksSlice } from "./thunks-slice/snackbar-thunks-slice"
88

99
addGeneratedCacheKeys()
1010

1111
export const rootReducer = combineReducers({
1212
snackbarReducer: snackbarThunksSlice.reducer,
13-
[statorApi.reducerPath]: statorApi.reducer,
13+
[api.reducerPath]: api.reducer,
1414
})
1515

1616
export type RootState = ReturnType<typeof rootReducer>
@@ -24,7 +24,7 @@ export const store = configureStore({
2424
serializableCheck: false,
2525
})
2626
.concat(errorMiddleware())
27-
.concat(statorApi.middleware),
27+
.concat(api.middleware),
2828
})
2929
setupListeners(store.dispatch)
3030

cli/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)