Add .devcontainer + minor changes
All checks were successful
forgejo/Procyon/seedling/pipeline/pr-master This commit looks good
forgejo/Procyon/seedling/pipeline/head This commit looks good

This commit is contained in:
Roman Jaroš 2023-12-22 17:48:27 +00:00
parent 99831ff824
commit 8aeff18162
16 changed files with 59 additions and 23 deletions

View file

@ -1,3 +1 @@
FROM local/nodejs/dev:18
USER node
FROM local/nodejs/dev:18

View file

@ -3,7 +3,7 @@
"workspaceFolder": "/home/project/seedling",
"dockerComposeFile": "docker-compose.yml",
"service": "seedling",
"postCreateCommand": "sudo chown node:node -R /home/project",
"postCreateCommand": "sudo chown iamuser:iamuser -R /home/project",
"customizations": {
"vscode": {
"extensions": [

1
.eslintignore Normal file
View file

@ -0,0 +1 @@
source/

1
.gitignore vendored
View file

@ -4,6 +4,7 @@ app/
node_modules/
.vscode/
.idea/
.pnpm/
.pnpm-store/

View file

@ -7,14 +7,14 @@ const argv = require('minimist')(process.argv.slice(2));
const appName = argv.name ?? 'app';
const appPort = argv.port ?? '0';
const defaultContextDir = './';
const defaultContextDir = '.';
const rootDir = __dirname;
const contextDir = `${argv._[0]}/` ?? defaultContextDir;
const contextDir = `${argv._[0] ?? defaultContextDir}`;
// create app folder
const appsDir = `${contextDir}/apps`;
const uiDir = `${contextDir}/apps/${appName}-ui`;
const apiDir = `${contextDir}/apps/${appName}-rest`;
const restDir = `${contextDir}/apps/${appName}-rest`;
// prepare structure folders
if (!fs.existsSync(uiDir)) {
@ -24,8 +24,8 @@ if (!fs.existsSync(uiDir)) {
fs.mkdirSync(appsDir);
fs.mkdirSync(uiDir);
fs.mkdirSync(`${uiDir}/src`);
fs.mkdirSync(apiDir);
fs.mkdirSync(`${apiDir}/src`);
fs.mkdirSync(restDir);
fs.mkdirSync(`${restDir}/src`);
}
// copy folder content
@ -38,7 +38,7 @@ try {
force: true,
recursive: true,
});
fs.cpSync(`${rootDir}/source/rest/`, apiDir, {
fs.cpSync(`${rootDir}/source/rest/`, restDir, {
force: true,
recursive: true,
});
@ -55,29 +55,29 @@ fs.renameSync(`${contextDir}/gitignore`, `${contextDir}/.gitignore`);
fs.renameSync(`${contextDir}/prettierrc`, `${contextDir}/.prettierrc`);
fs.renameSync(`${contextDir}/.tsconfig.json`, `${contextDir}/tsconfig.json`);
fs.renameSync(`${uiDir}/.tsconfig.json`, `${uiDir}/tsconfig.json`);
fs.renameSync(`${apiDir}/.tsconfig.json`, `${apiDir}/tsconfig.json`);
fs.renameSync(`${restDir}/.tsconfig.json`, `${restDir}/tsconfig.json`);
// replace in files
replaceInFiles.sync({
files: `./${contextDir}/**/*.{ts,tsx}`,
from: /\/\/.\@ts\-nocheck\n/gm,
files: [`${contextDir}/**/*`, `${contextDir}/.devcontainer/*`],
from: /\/\/.@ts-nocheck\n/gm,
to: '',
});
replaceInFiles.sync({
files: `./${contextDir}/**/*`,
files: [`${contextDir}/**/*`, `${contextDir}/.devcontainer/*`],
from: /\$\(appName\)/gm,
to: appName,
});
replaceInFiles.sync({
files: `./${contextDir}/**/*`,
files: [`${contextDir}/**/*`, `${contextDir}/.devcontainer/*`],
from: /\$\(AppName\)/gm,
to: appName.charAt(0).toUpperCase() + appName.slice(1),
});
replaceInFiles.sync({
files: `./${contextDir}/**/*`,
files: [`${contextDir}/**/*`, `${contextDir}/.devcontainer/*`],
from: /\$\(appPort\)/gm,
to: appPort,
});
// install deps
execSync(`pnpm i`, { cwd: `./${contextDir}` })
execSync(`pnpm i`, { cwd: `${contextDir}` });

View file

@ -12,7 +12,6 @@
"release": "pnpm version --no-git-tag-version"
},
"dependencies": {
"app": "link:app",
"minimist": "1.2.8",
"replace-in-file": "7.0.2"
},

3
pnpm-lock.yaml generated
View file

@ -5,9 +5,6 @@ settings:
excludeLinksFromLockfile: false
dependencies:
app:
specifier: link:app
version: link:app
minimist:
specifier: 1.2.8
version: 1.2.8

View file

@ -0,0 +1 @@
FROM local/nodejs/dev:18

View file

@ -0,0 +1,7 @@
{
"name": "$(appName)",
"workspaceFolder": "/home/project/$(appName)",
"dockerComposeFile": "docker-compose.yml",
"service": "$(appName)",
"postCreateCommand": "sudo chown iamuser:iamuser -R /home/project",
}

View file

@ -0,0 +1,18 @@
version: "3"
name: $(appName)
volumes:
node_modules:
pnpm-store:
services:
seedling:
build:
context: .
container_name: $(appName)
volumes:
- ../:/home/project/$(appName)
- node_modules:/home/project/seedling/node_modules
- pnpm-store:/home/project/seedling/.pnpm-store
command: sleep infinity

1
source/common/.env Normal file
View file

@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=$(appName)

View file

@ -1,7 +1,7 @@
const { merge } = require('webpack-merge');
const common = require('./webpack-common');
const myEnv = require('dotenv').config({ path: 'config/local/.env' }).parsed;
const myEnv = require('dotenv').config({ path: 'config/app/.env.local' }).parsed;
module.exports = (env, args) => {
return merge(common(env, args, myEnv), {

View file

@ -1,6 +1,6 @@
const { merge } = require('webpack-merge');
const myEnv = require('dotenv').config({ path: 'config/prod/.env' }).parsed;
const myEnv = require('dotenv').config({ path: 'config/app/.env.prod' }).parsed;
const common = require('./webpack-common');
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');

View file

@ -0,0 +1,13 @@
declare global {
interface Window {
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any;
}
namespace NodeJS {
interface ProcessEnv {
ENDPOINT_BASE_URL: string;
}
}
}
export default global;