-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove
protoc
pkg and also nodetime helpers ts-proto
and `s…
…ta` (backport #4090) (#4224) * feat: remove `protoc` pkg and also nodetime helpers `ts-proto` and `sta` (#4090) * remove protoc * add changelog * run go mod tidy * remove unused proto folder handling * add ts-client tests * remove unused methods * use import includes instead manual * use buf dep instead buf mod * change buf mod update to comand to buf dep update * improve code readbility * bump buf.build * bump buf into the go.mod * bump protobuf pkgs for buf * check if the folder has proto before update buf dependencies --------- Co-authored-by: Pantani <Pantani> (cherry picked from commit 8e0937d) # Conflicts: # go.mod # go.sum # ignite/internal/plugin/testdata/execute_fail/go.mod # ignite/internal/plugin/testdata/execute_ok/go.mod # ignite/internal/tools/gen-config-doc/go.mod # ignite/internal/tools/gen-config-doc/go.sum # ignite/internal/tools/gen-mig-diffs/go.mod # ignite/internal/tools/gen-mig-diffs/go.sum # ignite/pkg/cosmosbuf/buf.go # ignite/pkg/cosmosgen/generate_go.go # ignite/pkg/cosmosgen/generate_openapi.go # ignite/pkg/cosmosgen/generate_typescript.go # ignite/pkg/nodetime/nodetime.go # ignite/pkg/nodetime/programs/sta/sta.go # ignite/pkg/nodetime/programs/ts-proto/tsproto.go # ignite/pkg/protoc/protoc.go # ignite/templates/app/files/go.mod.plush # ignite/templates/app/files/proto/buf.lock # integration/doctor/testdata/missing-tools.go.txt # integration/plugin/testdata/example-plugin/go.mod * resolve conflicts * fix changelog * remove unused files * fix TestPluginExecute * fix tests for ts generation * rollback go version from tests * fix text namespace version for ts client generation --------- Co-authored-by: Danilo Pantani <[email protected]> Co-authored-by: Julien Robert <[email protected]>
- Loading branch information
1 parent
9e853ee
commit c1ae9c2
Showing
11 changed files
with
99 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package cosmosgen | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
const routeNameTemplate = `<% | ||
const { routeInfo, utils } = it; | ||
const { | ||
operationId, | ||
method, | ||
route, | ||
moduleName, | ||
responsesTypes, | ||
description, | ||
tags, | ||
summary, | ||
pathArgs, | ||
} = routeInfo; | ||
const { _, fmtToJSDocLine, require } = utils; | ||
const methodAliases = { | ||
get: (pathName, hasPathInserts) => | ||
_.camelCase(` + "`" + `${pathName}_${hasPathInserts ? "detail" : "list"}` + "`" + `), | ||
post: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_create` + "`" + `), | ||
put: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_update` + "`" + `), | ||
patch: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_partial_update` + "`" + `), | ||
delete: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_delete` + "`" + `), | ||
}; | ||
const createCustomOperationId = (method, route, moduleName) => { | ||
const hasPathInserts = /\{(\w){1,}\}/g.test(route); | ||
const splitedRouteBySlash = _.compact(_.replace(route, /\{(\w){1,}\}/g, "").split("/")); | ||
const routeParts = (splitedRouteBySlash.length > 1 | ||
? splitedRouteBySlash.splice(1) | ||
: splitedRouteBySlash | ||
).join("_"); | ||
return routeParts.length > 3 && methodAliases[method] | ||
? methodAliases[method](routeParts, hasPathInserts) | ||
: _.camelCase(_.lowerCase(method) + "_" + [moduleName].join("_")) || "index"; | ||
}; | ||
if (operationId) { | ||
let routeName = operationId.replace('_',''); | ||
return routeName[0].toLowerCase() + routeName.slice(1); | ||
} | ||
if (route === "/") | ||
return _.camelCase(` + "`" + `${_.lowerCase(method)}Root` + "`" + `); | ||
return createCustomOperationId(method, route, moduleName); | ||
%>` | ||
|
||
// generateRouteNameFile generates the `route-name.eta` file. | ||
func generateRouteNameFile(outPath string) error { | ||
outTemplate := filepath.Join(outPath, "route-name.eta") | ||
return os.WriteFile(outTemplate, []byte(routeNameTemplate), 0o644) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.