pwi-plata-type 0.2.18 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,7 +36,11 @@ export async function h() {
36
36
  console.log('CLUSTER AINDA NÃO CRIANDO AINDA')
37
37
  break;
38
38
  case 'route':
39
- const routeArg = `${args.shift()}`.split('/')
39
+ const r = `${args.shift()}/`.replace(/:(.*?)(?:\/|$)/g, (_, parm) => {
40
+ return parm[parm.length - 1] !== '?' ? `{${parm}}/` : `[${parm.slice(0, -1)}]/`
41
+ })
42
+
43
+ const routeArg = r.slice(0, -1).split('/')
40
44
 
41
45
  const routeFileName = routeArg[routeArg.length - 1] === '' ? 'index' : routeArg.pop()
42
46
  const routeFilePath = path.join('routes', ...routeArg.filter(v => v !== ''))
package/libs/routes.ts CHANGED
@@ -43,6 +43,9 @@ export async function loadExpressRoutes(): Promise<PlataRequiredRoute[]> {
43
43
  .replace(/.(ts|js)$/, '')
44
44
  .replace(/index/, '')
45
45
  .replace(/\\/g, '/')
46
+ .replace(/\{(.*?)\}/g, ':$1')
47
+ .replace(/\[(.*?)\]/g, ':$1?')
48
+ ;
46
49
 
47
50
  return route
48
51
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwi-plata-type",
3
- "version": "0.2.18",
3
+ "version": "0.2.21",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "bin": {
@@ -104,5 +104,12 @@ export function tools(dirs) {
104
104
  await tools.copyFile(templateFile, destination)
105
105
  }
106
106
 
107
+ tools.copyFileToProject = async (file) => {
108
+ const templateFile = path.join(dirs.templateDir, file)
109
+ const destination = path.join(dirs.projectDir, file)
110
+
111
+ await tools.copyFileIfNotExists(templateFile, destination)
112
+ }
113
+
107
114
  return tools
108
115
  }
@@ -15,7 +15,7 @@ export async function install({ dirs, projectPackageJson }) {
15
15
  promises.push(t.copyFolderToProject('envs'))
16
16
  promises.push(t.syncFolderProject('.vscode'))
17
17
 
18
- promises.push(t.syncFileToProject('Dockerfile'))
18
+ promises.push(t.copyFileToProject('Dockerfile'))
19
19
  promises.push(t.syncFileToProject('tsconfig.json'))
20
20
 
21
21
  projectPackageJson.type = "module"