create-platformatic 1.17.0 → 1.18.0
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/create-platformatic.mjs +1 -6
- package/package.json +6 -5
- package/src/ghaction.mjs +1 -0
- package/src/utils.mjs +2 -130
- package/src/ask-dir.mjs +0 -37
- package/src/cli-options.mjs +0 -34
- package/src/colors.mjs +0 -4
- package/src/composer/README.md +0 -30
- package/src/composer/create-composer-cli.mjs +0 -143
- package/src/composer/create-composer.mjs +0 -146
- package/src/create-git-repository.mjs +0 -105
- package/src/create-gitignore.mjs +0 -42
- package/src/create-package-json.mjs +0 -58
- package/src/create-plugins.mjs +0 -220
- package/src/create-readme.mjs +0 -12
- package/src/db/README.md +0 -38
- package/src/db/create-db-cli.mjs +0 -263
- package/src/db/create-db.mjs +0 -449
- package/src/get-tsconfig.mjs +0 -22
- package/src/index.mjs +0 -112
- package/src/runtime/README.md +0 -32
- package/src/runtime/create-runtime-cli.mjs +0 -199
- package/src/runtime/create-runtime.mjs +0 -128
- package/src/say.mjs +0 -20
- package/src/service/README.md +0 -31
- package/src/service/create-service-cli.mjs +0 -127
- package/src/service/create-service.mjs +0 -132
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { execa } from 'execa'
|
|
2
|
-
|
|
3
|
-
export const GIT_FIRST_COMMIT_MESSAGE = 'Platformatic project started! 🚀'
|
|
4
|
-
export const GIT_MAIN_BRANCH = 'main'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates a Git repository and performs the initial commit if it doesn't already exist.
|
|
8
|
-
*
|
|
9
|
-
* This function checks if Git is installed, initializes a Git repository in the specified
|
|
10
|
-
* directory if it's not already a Git repository, and performs the initial commit.
|
|
11
|
-
*
|
|
12
|
-
* @param {import('pino.').BaseLogger} logger - The logger interface for logging messages.
|
|
13
|
-
* @param {string} [dir='.'] - The target directory where the Git repository should be created.
|
|
14
|
-
*/
|
|
15
|
-
export async function createGitRepository (logger, dir = '.') {
|
|
16
|
-
if (!await isGitInstalled()) {
|
|
17
|
-
logger.error('Git is not installed')
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!await gitInit(logger, dir)) {
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!await gitCommit(logger, dir)) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
logger.info('Git repository initialized.')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Checks if Git is installed on the system.
|
|
34
|
-
*
|
|
35
|
-
* @async
|
|
36
|
-
* @returns {Promise<boolean>} A Promise that resolves to true if Git is installed, false otherwise.
|
|
37
|
-
*/
|
|
38
|
-
async function isGitInstalled () {
|
|
39
|
-
try {
|
|
40
|
-
await execa('git', ['--version'])
|
|
41
|
-
return true
|
|
42
|
-
} catch (err) {
|
|
43
|
-
return false
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Checks if a Git repository exists in the specified directory.
|
|
49
|
-
*
|
|
50
|
-
* @async
|
|
51
|
-
* @param {string} dir - The directory to check for a Git repository.
|
|
52
|
-
* @returns {Promise<boolean>} A Promise that resolves to true if a Git repository exists in the directory, false otherwise.
|
|
53
|
-
*/
|
|
54
|
-
async function doesGitRepositoryExist (dir) {
|
|
55
|
-
try {
|
|
56
|
-
await execa('git', ['rev-parse', '--is-inside-work-tree'], { cwd: dir })
|
|
57
|
-
return true
|
|
58
|
-
} catch (e) {
|
|
59
|
-
return false
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Initializes a Git repository in the specified directory if it doesn't already exist.
|
|
65
|
-
*
|
|
66
|
-
* @async
|
|
67
|
-
* @param {import('pino.').BaseLogger} - The logger object for logging messages.
|
|
68
|
-
* @param {string} dir - The directory where the Git repository should be initialized.
|
|
69
|
-
* @returns {Promise<boolean>} A Promise that resolves to true if the Git repository is successfully initialized, false otherwise.
|
|
70
|
-
*/
|
|
71
|
-
async function gitInit (logger, dir) {
|
|
72
|
-
try {
|
|
73
|
-
if (await doesGitRepositoryExist(dir)) {
|
|
74
|
-
logger.info('Git repository already exists.')
|
|
75
|
-
return false
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
await execa('git', ['init', '-b', GIT_MAIN_BRANCH], { cwd: dir })
|
|
79
|
-
logger.debug('Git repository initialized.')
|
|
80
|
-
return true
|
|
81
|
-
} catch (err) {
|
|
82
|
-
logger.error('Git repository init failed.', err)
|
|
83
|
-
return false
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Commits changes in a Git repository located in the specified directory.
|
|
89
|
-
*
|
|
90
|
-
* @async
|
|
91
|
-
* @param {import('pino.').BaseLogger} - The logger object for logging messages.
|
|
92
|
-
* @param {string} dir - The directory of the Git repository where changes should be committed.
|
|
93
|
-
* @returns {Promise<boolean>} A Promise that resolves to true if the Git commit is successful, false otherwise.
|
|
94
|
-
*/
|
|
95
|
-
async function gitCommit (logger, dir) {
|
|
96
|
-
try {
|
|
97
|
-
await execa('git', ['add', '-A'], { cwd: dir })
|
|
98
|
-
await execa('git', ['commit', '-m', GIT_FIRST_COMMIT_MESSAGE], { cwd: dir })
|
|
99
|
-
logger.debug('Git commit done.')
|
|
100
|
-
return true
|
|
101
|
-
} catch (err) {
|
|
102
|
-
logger.error('Git commit failed.', err)
|
|
103
|
-
return false
|
|
104
|
-
}
|
|
105
|
-
}
|
package/src/create-gitignore.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { writeFile } from 'fs/promises'
|
|
2
|
-
import { join } from 'node:path'
|
|
3
|
-
|
|
4
|
-
const gitignore = `\
|
|
5
|
-
dist
|
|
6
|
-
.DS_Store
|
|
7
|
-
|
|
8
|
-
# dotenv environment variable files
|
|
9
|
-
.env
|
|
10
|
-
|
|
11
|
-
# database files
|
|
12
|
-
*.sqlite
|
|
13
|
-
*.sqlite3
|
|
14
|
-
|
|
15
|
-
# Logs
|
|
16
|
-
logs
|
|
17
|
-
*.log
|
|
18
|
-
npm-debug.log*
|
|
19
|
-
yarn-debug.log*
|
|
20
|
-
yarn-error.log*
|
|
21
|
-
lerna-debug.log*
|
|
22
|
-
.pnpm-debug.log*
|
|
23
|
-
|
|
24
|
-
# Dependency directories
|
|
25
|
-
node_modules/
|
|
26
|
-
|
|
27
|
-
# ctags
|
|
28
|
-
tags
|
|
29
|
-
|
|
30
|
-
# clinicjs
|
|
31
|
-
.clinic/
|
|
32
|
-
`
|
|
33
|
-
/**
|
|
34
|
-
* Creates a standard Platformatic app .gitignore file
|
|
35
|
-
* @param {import('pino').BaseLogger} logger Logger Interface
|
|
36
|
-
* @param {string} dir Target directory
|
|
37
|
-
*/
|
|
38
|
-
export const createGitignore = async (logger, dir = '.') => {
|
|
39
|
-
const gitignoreFileName = join(dir, '.gitignore')
|
|
40
|
-
await writeFile(gitignoreFileName, gitignore)
|
|
41
|
-
logger.debug(`Gitignore file ${gitignoreFileName} successfully created.`)
|
|
42
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { writeFile, readFile } from 'fs/promises'
|
|
2
|
-
import { join } from 'node:path'
|
|
3
|
-
import { fileURLToPath } from 'node:url'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Creates a package.json template file
|
|
7
|
-
* @param {boolean} addTSBuild Whether to add TS Build or not
|
|
8
|
-
* @param {string} fastifyVersion Fastify Version
|
|
9
|
-
* @param {string} platVersion Platformatic Version
|
|
10
|
-
*/
|
|
11
|
-
const packageJsonTemplate = async (addTSBuild, fastifyVersion, platVersion) => {
|
|
12
|
-
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
13
|
-
|
|
14
|
-
const pkg = {
|
|
15
|
-
scripts: {
|
|
16
|
-
start: 'platformatic start',
|
|
17
|
-
test: 'node --test test/**'
|
|
18
|
-
},
|
|
19
|
-
devDependencies: {
|
|
20
|
-
fastify: `^${fastifyVersion}`
|
|
21
|
-
},
|
|
22
|
-
dependencies: {
|
|
23
|
-
platformatic: `^${platVersion}`
|
|
24
|
-
},
|
|
25
|
-
engines: {
|
|
26
|
-
node: '^18.8.0 || >=20.6.0'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (addTSBuild) {
|
|
31
|
-
const typescriptVersion = JSON.parse(await readFile(join(__dirname, '..', 'package.json'), 'utf-8')).devDependencies.typescript
|
|
32
|
-
pkg.scripts.clean = 'rm -fr ./dist'
|
|
33
|
-
pkg.scripts.build = 'platformatic compile'
|
|
34
|
-
pkg.devDependencies.typescript = typescriptVersion
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return pkg
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Creates a Platformatic app package.json file
|
|
42
|
-
* @param {string} platVersion Platformatic Version
|
|
43
|
-
* @param {string} fastifyVersion Fastify Version
|
|
44
|
-
* @param {import('pino').BaseLogger} logger Logger Interface
|
|
45
|
-
* @param {string} dir Target directory where to create the file
|
|
46
|
-
* @param {boolean} addTSBuild Whether to add TS Build or not
|
|
47
|
-
* @param {object} scripts Package.json scripts list
|
|
48
|
-
* @param {object} dependencies Package.json dependencies list
|
|
49
|
-
*/
|
|
50
|
-
export const createPackageJson = async (platVersion, fastifyVersion, logger, dir, addTSBuild = false, scripts = {}, dependencies = {}, devDependencies = {}) => {
|
|
51
|
-
const packageJsonFileName = join(dir, 'package.json')
|
|
52
|
-
const pkg = await packageJsonTemplate(addTSBuild, fastifyVersion, platVersion)
|
|
53
|
-
Object.assign(pkg.scripts, scripts)
|
|
54
|
-
Object.assign(pkg.dependencies, dependencies)
|
|
55
|
-
Object.assign(pkg.devDependencies, devDependencies)
|
|
56
|
-
await writeFile(packageJsonFileName, JSON.stringify(pkg, null, 2))
|
|
57
|
-
logger.debug(`${packageJsonFileName} successfully created.`)
|
|
58
|
-
}
|
package/src/create-plugins.mjs
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { join } from 'path'
|
|
2
|
-
import { writeFile } from 'fs/promises'
|
|
3
|
-
import { safeMkdir } from './utils.mjs'
|
|
4
|
-
|
|
5
|
-
const JS_PLUGIN_WITH_TYPES_SUPPORT = `\
|
|
6
|
-
/// <reference path="../global.d.ts" />
|
|
7
|
-
'use strict'
|
|
8
|
-
/** @param {import('fastify').FastifyInstance} fastify */
|
|
9
|
-
module.exports = async function (fastify, opts) {
|
|
10
|
-
fastify.decorate('example', 'foobar')
|
|
11
|
-
}
|
|
12
|
-
`
|
|
13
|
-
|
|
14
|
-
const TS_PLUGIN_WITH_TYPES_SUPPORT = `\
|
|
15
|
-
/// <reference path="../global.d.ts" />
|
|
16
|
-
import { FastifyInstance, FastifyPluginOptions } from 'fastify'
|
|
17
|
-
|
|
18
|
-
export default async function (fastify: FastifyInstance, opts: FastifyPluginOptions) {
|
|
19
|
-
fastify.decorate('example', 'foobar')
|
|
20
|
-
}
|
|
21
|
-
`
|
|
22
|
-
|
|
23
|
-
const JS_ROUTES_WITH_TYPES_SUPPORT = `\
|
|
24
|
-
/// <reference path="../global.d.ts" />
|
|
25
|
-
'use strict'
|
|
26
|
-
/** @param {import('fastify').FastifyInstance} fastify */
|
|
27
|
-
module.exports = async function (fastify, opts) {
|
|
28
|
-
fastify.get('/example', async (request, reply) => {
|
|
29
|
-
return { hello: fastify.example }
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
`
|
|
33
|
-
|
|
34
|
-
const TS_ROUTES_WITH_TYPES_SUPPORT = `\
|
|
35
|
-
/// <reference path="../global.d.ts" />
|
|
36
|
-
import { FastifyInstance, FastifyPluginOptions } from 'fastify'
|
|
37
|
-
|
|
38
|
-
declare module 'fastify' {
|
|
39
|
-
interface FastifyInstance {
|
|
40
|
-
example: string
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default async function (fastify: FastifyInstance, opts: FastifyPluginOptions) {
|
|
45
|
-
fastify.get('/example', async (request, reply) => {
|
|
46
|
-
return { hello: fastify.example }
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
function testHelperJS (mod, customization = { pre: '', post: '', config: '' }) {
|
|
52
|
-
return `\
|
|
53
|
-
'use strict'
|
|
54
|
-
|
|
55
|
-
const { join } = require('node:path')
|
|
56
|
-
const { readFile } = require('node:fs/promises')
|
|
57
|
-
const { buildServer } = require('@platformatic/${mod}')
|
|
58
|
-
${customization.requires || ''}
|
|
59
|
-
|
|
60
|
-
async function getServer (t) {
|
|
61
|
-
${customization.pre || ''}
|
|
62
|
-
const config = JSON.parse(await readFile(join(__dirname, '..', 'platformatic.${mod}.json'), 'utf8'))
|
|
63
|
-
// Add your config customizations here. For example you want to set
|
|
64
|
-
// all things that are set in the config file to read from an env variable
|
|
65
|
-
config.server.logger.level = 'warn'
|
|
66
|
-
config.watch = false
|
|
67
|
-
${customization.config || ''}
|
|
68
|
-
// Add your config customizations here
|
|
69
|
-
const server = await buildServer(config)
|
|
70
|
-
t.after(() => server.close())
|
|
71
|
-
${customization.post || ''}
|
|
72
|
-
return server
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
module.exports.getServer = getServer
|
|
76
|
-
`
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const TEST_ROUTES_JS = `\
|
|
80
|
-
'use strict'
|
|
81
|
-
|
|
82
|
-
const test = require('node:test')
|
|
83
|
-
const assert = require('node:assert')
|
|
84
|
-
const { getServer } = require('../helper')
|
|
85
|
-
|
|
86
|
-
test('example', async (t) => {
|
|
87
|
-
const server = await getServer(t)
|
|
88
|
-
const res = await server.inject({
|
|
89
|
-
method: 'GET',
|
|
90
|
-
url: '/example'
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
assert.strictEqual(res.statusCode, 200)
|
|
94
|
-
assert.deepStrictEqual(res.json(), {
|
|
95
|
-
hello: 'foobar'
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
`
|
|
99
|
-
|
|
100
|
-
const TEST_PLUGIN_JS = `\
|
|
101
|
-
'use strict'
|
|
102
|
-
|
|
103
|
-
const test = require('node:test')
|
|
104
|
-
const assert = require('node:assert')
|
|
105
|
-
const { getServer } = require('../helper')
|
|
106
|
-
|
|
107
|
-
test('example decorator', async (t) => {
|
|
108
|
-
const server = await getServer(t)
|
|
109
|
-
|
|
110
|
-
assert.strictEqual(server.example, 'foobar')
|
|
111
|
-
})
|
|
112
|
-
`
|
|
113
|
-
|
|
114
|
-
function testHelperTS (mod, customizations = { pre: '', post: '', config: '', requires: '' }) {
|
|
115
|
-
return `\
|
|
116
|
-
import { join } from 'node:path'
|
|
117
|
-
import { readFile } from 'node:fs/promises'
|
|
118
|
-
import { buildServer } from '@platformatic/${mod}'
|
|
119
|
-
import { test } from 'node:test'
|
|
120
|
-
${customizations.requires}
|
|
121
|
-
|
|
122
|
-
type testfn = Parameters<typeof test>[0]
|
|
123
|
-
type TestContext = Parameters<Exclude<testfn, undefined>>[0]
|
|
124
|
-
|
|
125
|
-
export async function getServer (t: TestContext) {
|
|
126
|
-
${customizations.pre}
|
|
127
|
-
// We go up two folder because this files executes in the dist folder
|
|
128
|
-
const config = JSON.parse(await readFile(join(__dirname, '..', '..', 'platformatic.${mod}.json'), 'utf8'))
|
|
129
|
-
// Add your config customizations here. For example you want to set
|
|
130
|
-
// all things that are set in the config file to read from an env variable
|
|
131
|
-
config.server.logger.level = 'warn'
|
|
132
|
-
config.watch = false
|
|
133
|
-
${customizations.config}
|
|
134
|
-
// Add your config customizations here
|
|
135
|
-
const server = await buildServer(config)
|
|
136
|
-
t.after(() => server.close())
|
|
137
|
-
${customizations.post}
|
|
138
|
-
return server
|
|
139
|
-
}
|
|
140
|
-
`
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const TEST_ROUTES_TS = `\
|
|
144
|
-
import test from 'node:test'
|
|
145
|
-
import assert from 'node:assert'
|
|
146
|
-
import { getServer } from '../helper'
|
|
147
|
-
|
|
148
|
-
test('root', async (t) => {
|
|
149
|
-
const server = await getServer(t)
|
|
150
|
-
const res = await server.inject({
|
|
151
|
-
method: 'GET',
|
|
152
|
-
url: '/example'
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
assert.strictEqual(res.statusCode, 200)
|
|
156
|
-
assert.deepStrictEqual(res.json(), {
|
|
157
|
-
hello: 'foobar'
|
|
158
|
-
})
|
|
159
|
-
})
|
|
160
|
-
`
|
|
161
|
-
|
|
162
|
-
const TEST_PLUGIN_TS = `\
|
|
163
|
-
import test from 'node:test'
|
|
164
|
-
import assert from 'node:assert'
|
|
165
|
-
import { getServer } from '../helper'
|
|
166
|
-
|
|
167
|
-
test('example decorator', async (t) => {
|
|
168
|
-
const server = await getServer(t)
|
|
169
|
-
|
|
170
|
-
assert.strictEqual(server.example, 'foobar')
|
|
171
|
-
})
|
|
172
|
-
`
|
|
173
|
-
|
|
174
|
-
export async function generatePluginWithTypesSupport (logger, currentDir, isTypescript) {
|
|
175
|
-
await safeMkdir(join(currentDir, 'plugins'))
|
|
176
|
-
const pluginTemplate = isTypescript
|
|
177
|
-
? TS_PLUGIN_WITH_TYPES_SUPPORT
|
|
178
|
-
: JS_PLUGIN_WITH_TYPES_SUPPORT
|
|
179
|
-
const pluginName = isTypescript
|
|
180
|
-
? 'example.ts'
|
|
181
|
-
: 'example.js'
|
|
182
|
-
await writeFile(join(currentDir, 'plugins', pluginName), pluginTemplate)
|
|
183
|
-
logger.info('Plugins folder "plugins" successfully created.')
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export async function generateRouteWithTypesSupport (logger, currentDir, isTypescript) {
|
|
187
|
-
await safeMkdir(join(currentDir, 'routes'))
|
|
188
|
-
const routesTemplate = isTypescript
|
|
189
|
-
? TS_ROUTES_WITH_TYPES_SUPPORT
|
|
190
|
-
: JS_ROUTES_WITH_TYPES_SUPPORT
|
|
191
|
-
const routesName = isTypescript
|
|
192
|
-
? 'root.ts'
|
|
193
|
-
: 'root.js'
|
|
194
|
-
await writeFile(join(currentDir, 'routes', routesName), routesTemplate)
|
|
195
|
-
logger.info('Routes folder "routes" successfully created.')
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export async function generateTests (logger, currentDir, isTypescript, mod, customizations) {
|
|
199
|
-
await safeMkdir(join(currentDir, 'test'))
|
|
200
|
-
await safeMkdir(join(currentDir, 'test', 'plugins'))
|
|
201
|
-
await safeMkdir(join(currentDir, 'test', 'routes'))
|
|
202
|
-
|
|
203
|
-
if (isTypescript) {
|
|
204
|
-
await writeFile(join(currentDir, 'test', 'helper.ts'), testHelperTS(mod, customizations))
|
|
205
|
-
await writeFile(join(currentDir, 'test', 'plugins', 'example.test.ts'), TEST_PLUGIN_TS)
|
|
206
|
-
await writeFile(join(currentDir, 'test', 'routes', 'root.test.ts'), TEST_ROUTES_TS)
|
|
207
|
-
} else {
|
|
208
|
-
await writeFile(join(currentDir, 'test', 'helper.js'), testHelperJS(mod, customizations))
|
|
209
|
-
await writeFile(join(currentDir, 'test', 'plugins', 'example.test.js'), TEST_PLUGIN_JS)
|
|
210
|
-
await writeFile(join(currentDir, 'test', 'routes', 'root.test.js'), TEST_ROUTES_JS)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
logger.info('Test folder "tests" successfully created.')
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export async function generatePlugins (logger, currentDir, isTypescript, mod, helperCustomization) {
|
|
217
|
-
await generatePluginWithTypesSupport(logger, currentDir, isTypescript)
|
|
218
|
-
await generateRouteWithTypesSupport(logger, currentDir, isTypescript)
|
|
219
|
-
await generateTests(logger, currentDir, isTypescript, mod, helperCustomization)
|
|
220
|
-
}
|
package/src/create-readme.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
import { readFile, writeFile } from 'fs/promises'
|
|
3
|
-
import { join as desmJoin } from 'desm'
|
|
4
|
-
import { join } from 'path'
|
|
5
|
-
|
|
6
|
-
export const createReadme = async (logger, dir = '.', type) => {
|
|
7
|
-
const readmeFileTarget = join(dir, 'README.md')
|
|
8
|
-
const readmeFileSource = desmJoin(import.meta.url, type, 'README.md')
|
|
9
|
-
const readme = await readFile(readmeFileSource, 'utf-8')
|
|
10
|
-
await writeFile(readmeFileTarget, readme)
|
|
11
|
-
logger.debug(`${readmeFileTarget} successfully created.`)
|
|
12
|
-
}
|
package/src/db/README.md
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Platformatic DB API
|
|
2
|
-
|
|
3
|
-
This is a generated [Platformatic DB](https://docs.platformatic.dev/docs/reference/db/introduction) application.
|
|
4
|
-
|
|
5
|
-
## Requirements
|
|
6
|
-
|
|
7
|
-
Platformatic supports macOS, Linux and Windows ([WSL](https://docs.microsoft.com/windows/wsl/) recommended).
|
|
8
|
-
You'll need to have [Node.js](https://nodejs.org/) >= v18.8.0 or >= v20.6.0
|
|
9
|
-
|
|
10
|
-
## Setup
|
|
11
|
-
|
|
12
|
-
1. Install dependencies:
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
npm install
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
2. Apply migrations:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm run migrate
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
Run the API with:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
npm start
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Explore
|
|
34
|
-
- ⚡ The Platformatic DB server is running at http://localhost:3042/
|
|
35
|
-
- 📔 View the REST API's Swagger documentation at http://localhost:3042/documentation/
|
|
36
|
-
- 🔍 Try out the GraphiQL web UI at http://localhost:3042/graphiql
|
|
37
|
-
|
|
38
|
-
|