velocious 1.0.89 → 1.0.90
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.
package/package.json
CHANGED
package/src/cli/commands/init.js
CHANGED
|
@@ -1,56 +1,8 @@
|
|
|
1
1
|
import BaseCommand from "../base-command.js"
|
|
2
|
-
import fileExists from "../../utils/file-exists.js"
|
|
3
|
-
import fs from "fs/promises"
|
|
4
2
|
|
|
5
3
|
export default class VelociousCliCommandsInit extends BaseCommand {
|
|
6
4
|
async execute() {
|
|
7
|
-
|
|
8
|
-
const projectPath = this.getConfiguration()?.getDirectory() || process.cwd()
|
|
9
|
-
const projectConfigPath = `${projectPath}/src/config`
|
|
10
|
-
const fileMappings = [
|
|
11
|
-
{
|
|
12
|
-
source: `${velociousPath}/src/templates/configuration.js`,
|
|
13
|
-
target: `${projectConfigPath}/configuration.js`
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
source: `${velociousPath}/src/templates/routes.js`,
|
|
17
|
-
target: `${projectConfigPath}/routes.js`
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
const paths = [
|
|
21
|
-
projectConfigPath,
|
|
22
|
-
`${projectPath}/src/database/migrations`,
|
|
23
|
-
`${projectPath}/src/models`,
|
|
24
|
-
`${projectPath}/src/routes`
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
if (this.args.testing) {
|
|
28
|
-
return {
|
|
29
|
-
fileMappings
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
for (const path of paths) {
|
|
34
|
-
if (await fileExists(path)) {
|
|
35
|
-
console.log(`Config dir already exists: ${path}`)
|
|
36
|
-
} else {
|
|
37
|
-
console.log(`Config dir doesn't exists: ${path}`)
|
|
38
|
-
await fs.mkdir(path, {recursive: true})
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
for (const fileMapping of fileMappings) {
|
|
43
|
-
if (!await fileExists(fileMapping.source)) {
|
|
44
|
-
throw new Error(`Template doesn't exist: ${fileMapping.source}`)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (await fileExists(fileMapping.target)) {
|
|
48
|
-
console.log(`File already exists: ${fileMapping.target}`)
|
|
49
|
-
} else {
|
|
50
|
-
console.log(`File doesnt exist: ${fileMapping.target}`)
|
|
51
|
-
await fs.copyFile(fileMapping.source, fileMapping.target)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
5
|
+
return await this.getConfiguration().getEnvironmentHandler().cliCommandsInit(this)
|
|
54
6
|
}
|
|
55
7
|
}
|
|
56
8
|
|
|
@@ -15,6 +15,10 @@ export default class VelociousEnvironmentsHandlerBrowser extends Base {
|
|
|
15
15
|
this.migrationsRequireContextCallback = migrationsRequireContextCallback
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
async cliCommandsInit(_command) { // eslint-disable-line no-unused-vars
|
|
19
|
+
throw new Error("Unsupported on browser")
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
async cliCommandsMigrationGenerate(_command) { // eslint-disable-line no-unused-vars
|
|
19
23
|
throw new Error("Unsupported on browser")
|
|
20
24
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import BaseCommand from "../../../../cli/base-command.js"
|
|
2
|
+
import fileExists from "../../../../utils/file-exists.js"
|
|
3
|
+
import fs from "fs/promises"
|
|
4
|
+
|
|
5
|
+
export default class VelociousCliCommandsInit extends BaseCommand {
|
|
6
|
+
async execute() {
|
|
7
|
+
const velociousPath = await this.getEnvironmentHandler().getVelociousPath()
|
|
8
|
+
const projectPath = this.getConfiguration()?.getDirectory() || process.cwd()
|
|
9
|
+
const projectConfigPath = `${projectPath}/src/config`
|
|
10
|
+
const fileMappings = [
|
|
11
|
+
{
|
|
12
|
+
source: `${velociousPath}/src/templates/configuration.js`,
|
|
13
|
+
target: `${projectConfigPath}/configuration.js`
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
source: `${velociousPath}/src/templates/routes.js`,
|
|
17
|
+
target: `${projectConfigPath}/routes.js`
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
const paths = [
|
|
21
|
+
projectConfigPath,
|
|
22
|
+
`${projectPath}/src/database/migrations`,
|
|
23
|
+
`${projectPath}/src/models`,
|
|
24
|
+
`${projectPath}/src/routes`
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
if (this.args.testing) {
|
|
28
|
+
return {
|
|
29
|
+
fileMappings
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (const path of paths) {
|
|
34
|
+
if (await fileExists(path)) {
|
|
35
|
+
console.log(`Config dir already exists: ${path}`)
|
|
36
|
+
} else {
|
|
37
|
+
console.log(`Config dir doesn't exists: ${path}`)
|
|
38
|
+
await fs.mkdir(path, {recursive: true})
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (const fileMapping of fileMappings) {
|
|
43
|
+
if (!await fileExists(fileMapping.source)) {
|
|
44
|
+
throw new Error(`Template doesn't exist: ${fileMapping.source}`)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (await fileExists(fileMapping.target)) {
|
|
48
|
+
console.log(`File already exists: ${fileMapping.target}`)
|
|
49
|
+
} else {
|
|
50
|
+
console.log(`File doesnt exist: ${fileMapping.target}`)
|
|
51
|
+
await fs.copyFile(fileMapping.source, fileMapping.target)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const dontLoadConfiguration = true
|
|
58
|
+
|
|
59
|
+
export {dontLoadConfiguration}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Base from "./base.js"
|
|
2
2
|
import CliCommandsDestroyMigration from "./node/cli/commands/destroy/migration.js"
|
|
3
|
+
import CliCommandsInit from "./node/cli/commands/init.js"
|
|
3
4
|
import CliCommandsGenerateMigration from "./node/cli/commands/generate/migration.js"
|
|
4
5
|
import CliCommandsGenerateModel from "./node/cli/commands/generate/model.js"
|
|
5
6
|
import {dirname} from "path"
|
|
@@ -45,6 +46,10 @@ export default class VelociousEnvironmentHandlerNode extends Base{
|
|
|
45
46
|
return commands
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
async cliCommandsInit(command) {
|
|
50
|
+
return await this.forwardCommand(command, CliCommandsInit)
|
|
51
|
+
}
|
|
52
|
+
|
|
48
53
|
async cliCommandsMigrationGenerate(command) {
|
|
49
54
|
return await this.forwardCommand(command, CliCommandsGenerateMigration)
|
|
50
55
|
}
|