5htp 0.0.8 → 0.0.9-2
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 +2 -2
- package/skeleton/src/client/assets/theme.less +4 -4
- package/skeleton/src/client/pages/app/index.tsx +1 -1
- package/skeleton/src/client/pages/landing/_layout/index.less +1 -1
- package/skeleton/src/server/routes/general.ts +1 -1
- package/src/compiler/common/files/images.ts +1 -1
- package/src/compiler/common/utils/fixNpmLink.ts +46 -0
- package/src/compiler/index.ts +24 -15
- package/src/compiler/server/index.ts +28 -4
- package/skeleton/.github/workflows/ci.yml +0 -93
- package/skeleton/.github/workflows/ecs-task.json +0 -77
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp",
|
|
3
3
|
"description": "5-HTP, scientifically called 5-Hydroxytryptophan, is the precursor of happiness neurotransmitter.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9-2",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-cli.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"replace-once": "^1.0.0",
|
|
73
73
|
"speed-measure-webpack-plugin": "^1.5.0",
|
|
74
74
|
"terser-webpack-plugin": "^5.2.4",
|
|
75
|
-
"ts-alias": "^0.0.5",
|
|
75
|
+
"ts-alias": "^0.0.5-1",
|
|
76
76
|
"ts-node": "^10.9.1",
|
|
77
77
|
"tslog": "^3.3.4",
|
|
78
78
|
"webfont": "^11.2.26",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
// Spacing
|
|
22
22
|
@spacing: 1.2em;
|
|
23
|
-
@
|
|
23
|
+
@spacing: @spacing;
|
|
24
24
|
@spacingLayout: @spacing * 2;
|
|
25
25
|
|
|
26
26
|
// Responsive
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
--pageWidth: @pageWidth;
|
|
59
59
|
--focusWidth: @focusWidth;
|
|
60
60
|
|
|
61
|
-
--
|
|
62
|
-
--
|
|
61
|
+
--cAccent: @c1;
|
|
62
|
+
--cAccent2: @c2;
|
|
63
63
|
|
|
64
64
|
--bgOverlay: fade(@c1 + #666, 70%);
|
|
65
65
|
|
|
@@ -148,7 +148,7 @@ i.solid {
|
|
|
148
148
|
|
|
149
149
|
&.c1,
|
|
150
150
|
&.primary {
|
|
151
|
-
.build-theme(@c1, @c1 + #aaa);
|
|
151
|
+
.build-theme-bg(@c1, @c1 + #aaa);
|
|
152
152
|
|
|
153
153
|
@cBgHighlight: @c1 + #111;
|
|
154
154
|
--cBgHighlight: @cBgHighlight;
|
|
@@ -5,7 +5,7 @@ import type App from '../../../app';
|
|
|
5
5
|
module.exports = (app: App, dev: boolean, client: boolean): webpack.RuleSetRule[] => {
|
|
6
6
|
|
|
7
7
|
return [{
|
|
8
|
-
test: /\.(bmp|gif|jpg|jpeg|png|ico|svg)$/,
|
|
8
|
+
test: /\.(bmp|gif|jpg|jpeg|png|ico|svg|webp)$/,
|
|
9
9
|
type: 'asset',
|
|
10
10
|
parser: {
|
|
11
11
|
dataUrlCondition: {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*----------------------------------
|
|
2
|
+
- DEPENDANCES
|
|
3
|
+
----------------------------------*/
|
|
4
|
+
|
|
5
|
+
// Npm
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
|
|
9
|
+
// App
|
|
10
|
+
import type App from '../../../app';
|
|
11
|
+
|
|
12
|
+
/*----------------------------------
|
|
13
|
+
- TYPES
|
|
14
|
+
----------------------------------*/
|
|
15
|
+
|
|
16
|
+
/*----------------------------------
|
|
17
|
+
- UTTILS
|
|
18
|
+
----------------------------------*/
|
|
19
|
+
export const fixNpmLinkIssues = ( app: App ) => {
|
|
20
|
+
|
|
21
|
+
const corePath = path.join(app.paths.root, '/node_modules/5htp-core');
|
|
22
|
+
if (!fs.lstatSync( corePath ).isSymbolicLink())
|
|
23
|
+
return;
|
|
24
|
+
|
|
25
|
+
console.info(`Fix NPM link issues ...`);
|
|
26
|
+
|
|
27
|
+
const appModules = path.join(app.paths.root, 'node_modules');
|
|
28
|
+
const coreModules = path.join(corePath, 'node_modules');
|
|
29
|
+
|
|
30
|
+
// When the 5htp package is installed from npm link,
|
|
31
|
+
// Modules are installed locally and not glbally as with with the 5htp package from NPM.
|
|
32
|
+
// So we need to symbilnk the http-core node_modules in one of the parents of server.js.
|
|
33
|
+
// It avoids errors like: "Error: Cannot find module 'intl'"
|
|
34
|
+
fs.symlinkSync( coreModules, path.join(app.paths.bin, 'node_modules') );
|
|
35
|
+
|
|
36
|
+
// Same problem: when 5htp-core is installed via npm link,
|
|
37
|
+
// Typescript doesn't detect React and shows mission JSX errors
|
|
38
|
+
const preactCoreModule = path.join(coreModules, 'preact');
|
|
39
|
+
const preactAppModule = path.join(appModules, 'preact');
|
|
40
|
+
const reactAppModule = path.join(appModules, 'react');
|
|
41
|
+
|
|
42
|
+
if (!fs.existsSync( preactAppModule ))
|
|
43
|
+
fs.symlinkSync( preactCoreModule, preactAppModule );
|
|
44
|
+
if (!fs.existsSync( reactAppModule ))
|
|
45
|
+
fs.symlinkSync( path.join(preactCoreModule, 'compat'), reactAppModule );
|
|
46
|
+
}
|
package/src/compiler/index.ts
CHANGED
|
@@ -14,10 +14,9 @@ const smp = new SpeedMeasurePlugin({ disable: true });
|
|
|
14
14
|
import createServerConfig from './server';
|
|
15
15
|
import createClientConfig from './client';
|
|
16
16
|
import { TCompileMode } from './common';
|
|
17
|
-
import
|
|
17
|
+
import { fixNpmLinkIssues } from './common/utils/fixNpmLink';
|
|
18
18
|
|
|
19
19
|
// types
|
|
20
|
-
|
|
21
20
|
import type App from '../app';
|
|
22
21
|
|
|
23
22
|
type TCompilerCallback = () => void
|
|
@@ -40,19 +39,28 @@ export default async function createCompilers(
|
|
|
40
39
|
fs.emptyDirSync( app.paths.bin );
|
|
41
40
|
fs.ensureDirSync( path.join(app.paths.bin, 'public') )
|
|
42
41
|
const publicFiles = fs.readdirSync(app.paths.public);
|
|
43
|
-
for (const publicFile of publicFiles)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
for (const publicFile of publicFiles) {
|
|
43
|
+
// Dev: faster to use symlink
|
|
44
|
+
if (mode === 'dev')
|
|
45
|
+
fs.symlinkSync(
|
|
46
|
+
path.join(app.paths.public, publicFile),
|
|
47
|
+
path.join(app.paths.bin, 'public', publicFile)
|
|
48
|
+
);
|
|
49
|
+
// Prod: Symlink not always supported by CI / Containers solutions
|
|
50
|
+
else
|
|
51
|
+
fs.copySync(
|
|
52
|
+
path.join(app.paths.public, publicFile),
|
|
53
|
+
path.join(app.paths.bin, 'public', publicFile)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* FIX issue with npm link
|
|
58
|
+
When we install a module with npm link, this module's deps are not installed in the parent project scope
|
|
59
|
+
Which causes some issues:
|
|
60
|
+
- The module's deps are not found by Typescript
|
|
61
|
+
- Including React, so VSCode shows that JSX is missing
|
|
62
|
+
*/
|
|
63
|
+
fixNpmLinkIssues(app);
|
|
56
64
|
|
|
57
65
|
// Create compilers
|
|
58
66
|
const multiCompiler = webpack([
|
|
@@ -93,6 +101,7 @@ export default async function createCompilers(
|
|
|
93
101
|
const time = timeEnd.getTime() - timeStart.getTime();
|
|
94
102
|
if (stats.hasErrors()) {
|
|
95
103
|
console.error(`############## Failed to compile '${name}' after ${time} ms`);
|
|
104
|
+
process.exit(0);
|
|
96
105
|
} else {
|
|
97
106
|
console.info(`############## [${name}] Finished compilation after ${time} ms`);
|
|
98
107
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
// Npm
|
|
6
6
|
import webpack from 'webpack';
|
|
7
|
+
import fs from 'fs-extra';
|
|
7
8
|
|
|
8
9
|
// Minimizers
|
|
9
10
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
@@ -16,6 +17,23 @@ import createCommonConfig, { TCompileMode, regex } from '../common';
|
|
|
16
17
|
// Type
|
|
17
18
|
import type App from '../../app';
|
|
18
19
|
|
|
20
|
+
const getCorePluginsList = (app: App,) => {
|
|
21
|
+
|
|
22
|
+
const corePlugins: string[] = [];
|
|
23
|
+
|
|
24
|
+
if (fs.existsSync( app.paths.root + '/node_modules' ))
|
|
25
|
+
for (const moduleName of fs.readdirSync( app.paths.root + '/node_modules' ))
|
|
26
|
+
if (moduleName.startsWith('5htp-'))
|
|
27
|
+
corePlugins.push(app.paths.root + '/node_modules/' + moduleName + '/src');
|
|
28
|
+
|
|
29
|
+
if (fs.existsSync( cli.paths.core.root + '/node_modules' ))
|
|
30
|
+
for (const moduleName of fs.readdirSync( cli.paths.core.root+ '/node_modules' ))
|
|
31
|
+
if (moduleName.startsWith('5htp-'))
|
|
32
|
+
corePlugins.push(cli.paths.core.root + '/node_modules/' + moduleName + '/src');
|
|
33
|
+
|
|
34
|
+
return corePlugins;
|
|
35
|
+
}
|
|
36
|
+
|
|
19
37
|
/*----------------------------------
|
|
20
38
|
- CONFIG
|
|
21
39
|
----------------------------------*/
|
|
@@ -70,11 +88,14 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
70
88
|
function ({ request }, callback) {
|
|
71
89
|
|
|
72
90
|
const shouldCompile = request !== undefined && (
|
|
73
|
-
|
|
74
|
-
||
|
|
75
|
-
request[0] === '/'
|
|
91
|
+
// Local files
|
|
92
|
+
request[0] === '.' || request[0] === '/'
|
|
76
93
|
||
|
|
94
|
+
// Aliased modules
|
|
77
95
|
app.aliases.server.containsAlias(request)
|
|
96
|
+
||
|
|
97
|
+
// Compile 5HTP modules
|
|
98
|
+
request.startsWith('5htp-')
|
|
78
99
|
)
|
|
79
100
|
|
|
80
101
|
//console.log('isNodeModule', request, isNodeModule);
|
|
@@ -119,7 +140,10 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
119
140
|
|
|
120
141
|
// Dossiers server uniquement pour le bundle server
|
|
121
142
|
app.paths.root + '/src/server',
|
|
122
|
-
cli.paths.core.root + '/src/server'
|
|
143
|
+
cli.paths.core.root + '/src/server',
|
|
144
|
+
|
|
145
|
+
// Complle 5HTP modules so they can refer to the framework instance and aliases
|
|
146
|
+
...getCorePluginsList(app)
|
|
123
147
|
],
|
|
124
148
|
rules: require('../common/babel')(app, 'server', dev)
|
|
125
149
|
},
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
name: Node.js CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
env:
|
|
8
|
-
AWS_REGION: eu-west-3
|
|
9
|
-
ECR_REPOSITORY: megacharger
|
|
10
|
-
ECS_SERVICE: megacharger
|
|
11
|
-
ECS_CLUSTER: main-cluster
|
|
12
|
-
ECS_TASK_DEFINITION: .github/workflows/ecs-task.json
|
|
13
|
-
CONTAINER_NAME: megacharger
|
|
14
|
-
|
|
15
|
-
jobs:
|
|
16
|
-
build:
|
|
17
|
-
name: Build
|
|
18
|
-
runs-on: ubuntu-latest
|
|
19
|
-
steps:
|
|
20
|
-
# git pull
|
|
21
|
-
- uses: actions/checkout@v3
|
|
22
|
-
# Use Node.JS
|
|
23
|
-
- name: Use Node.js
|
|
24
|
-
uses: actions/setup-node@v3
|
|
25
|
-
with:
|
|
26
|
-
node-version: '18.x'
|
|
27
|
-
# Install node deps
|
|
28
|
-
- run: npm ci
|
|
29
|
-
# Install 5htp CLI
|
|
30
|
-
- run: npm i --prefix=$HOME/.local -g 5htp;
|
|
31
|
-
# Buold app
|
|
32
|
-
- run: 5htp build
|
|
33
|
-
|
|
34
|
-
- uses: actions/upload-artifact@v2
|
|
35
|
-
with:
|
|
36
|
-
name: built-app
|
|
37
|
-
path: |
|
|
38
|
-
./bin
|
|
39
|
-
./public
|
|
40
|
-
./package.json
|
|
41
|
-
./package-lock.json
|
|
42
|
-
./identity.yaml
|
|
43
|
-
./Dockerfile
|
|
44
|
-
./.github/workflows/ecs-task.json
|
|
45
|
-
|
|
46
|
-
deploy:
|
|
47
|
-
name: Deploy
|
|
48
|
-
runs-on: ubuntu-latest
|
|
49
|
-
environment: production
|
|
50
|
-
needs: build
|
|
51
|
-
steps:
|
|
52
|
-
- uses: actions/download-artifact@v2
|
|
53
|
-
with:
|
|
54
|
-
name: built-app
|
|
55
|
-
|
|
56
|
-
- name: Configure AWS credentials
|
|
57
|
-
uses: aws-actions/configure-aws-credentials@13d241b293754004c80624b5567555c4a39ffbe3
|
|
58
|
-
with:
|
|
59
|
-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
60
|
-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
61
|
-
aws-region: ${{ env.AWS_REGION }}
|
|
62
|
-
|
|
63
|
-
- run: ls -al
|
|
64
|
-
|
|
65
|
-
- name: Login to Amazon ECR
|
|
66
|
-
id: login-ecr
|
|
67
|
-
uses: aws-actions/amazon-ecr-login@aaf69d68aa3fb14c1d5a6be9ac61fe15b48453a2
|
|
68
|
-
|
|
69
|
-
- name: Build, tag, and push image to Amazon ECR
|
|
70
|
-
id: build-image
|
|
71
|
-
env:
|
|
72
|
-
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
|
73
|
-
IMAGE_TAG: ${{ github.sha }}
|
|
74
|
-
run: |
|
|
75
|
-
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
|
|
76
|
-
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
|
|
77
|
-
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
|
|
78
|
-
|
|
79
|
-
- name: Fill in the new image ID in the Amazon ECS task definition
|
|
80
|
-
id: task-def
|
|
81
|
-
uses: aws-actions/amazon-ecs-render-task-definition@97587c9d45a4930bf0e3da8dd2feb2a463cf4a3a
|
|
82
|
-
with:
|
|
83
|
-
task-definition: ${{ env.ECS_TASK_DEFINITION }}
|
|
84
|
-
container-name: ${{ env.CONTAINER_NAME }}
|
|
85
|
-
image: ${{ steps.build-image.outputs.image }}
|
|
86
|
-
|
|
87
|
-
- name: Deploy Amazon ECS task definition
|
|
88
|
-
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
|
|
89
|
-
with:
|
|
90
|
-
task-definition: ${{ steps.task-def.outputs.task-definition }}
|
|
91
|
-
service: ${{ env.ECS_SERVICE }}
|
|
92
|
-
cluster: ${{ env.ECS_CLUSTER }}
|
|
93
|
-
wait-for-service-stability: true
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"taskDefinitionArn": "arn:aws:ecs:eu-west-3:909466428160:task-definition/run-app:8",
|
|
3
|
-
"containerDefinitions": [
|
|
4
|
-
{
|
|
5
|
-
"name": "megacharger",
|
|
6
|
-
"image": "909466428160.dkr.ecr.eu-west-3.amazonaws.com/megacharger",
|
|
7
|
-
"cpu": 0,
|
|
8
|
-
"portMappings": [
|
|
9
|
-
{
|
|
10
|
-
"containerPort": 3010,
|
|
11
|
-
"hostPort": 3010,
|
|
12
|
-
"protocol": "tcp"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"essential": true,
|
|
16
|
-
"environment": [],
|
|
17
|
-
"mountPoints": [],
|
|
18
|
-
"volumesFrom": [],
|
|
19
|
-
"logConfiguration": {
|
|
20
|
-
"logDriver": "awslogs",
|
|
21
|
-
"options": {
|
|
22
|
-
"awslogs-group": "/ecs/run-app",
|
|
23
|
-
"awslogs-region": "eu-west-3",
|
|
24
|
-
"awslogs-stream-prefix": "ecs"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"family": "run-app",
|
|
30
|
-
"taskRoleArn": "arn:aws:iam::909466428160:role/ecsTaskExecutionRole",
|
|
31
|
-
"executionRoleArn": "arn:aws:iam::909466428160:role/ecsTaskExecutionRole",
|
|
32
|
-
"networkMode": "awsvpc",
|
|
33
|
-
"revision": 8,
|
|
34
|
-
"volumes": [],
|
|
35
|
-
"status": "ACTIVE",
|
|
36
|
-
"requiresAttributes": [
|
|
37
|
-
{
|
|
38
|
-
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"name": "ecs.capability.execution-role-awslogs"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"name": "com.amazonaws.ecs.capability.ecr-auth"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"name": "com.amazonaws.ecs.capability.task-iam-role"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"name": "ecs.capability.execution-role-ecr-pull"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"name": "ecs.capability.task-eni"
|
|
60
|
-
}
|
|
61
|
-
],
|
|
62
|
-
"placementConstraints": [],
|
|
63
|
-
"compatibilities": [
|
|
64
|
-
"EC2",
|
|
65
|
-
"FARGATE"
|
|
66
|
-
],
|
|
67
|
-
"runtimePlatform": {
|
|
68
|
-
"operatingSystemFamily": "LINUX"
|
|
69
|
-
},
|
|
70
|
-
"requiresCompatibilities": [
|
|
71
|
-
"FARGATE"
|
|
72
|
-
],
|
|
73
|
-
"cpu": "256",
|
|
74
|
-
"memory": "512",
|
|
75
|
-
"registeredAt": "2022-10-17T11:13:18.185000+02:00",
|
|
76
|
-
"registeredBy": "arn:aws:iam::909466428160:user/github-ci"
|
|
77
|
-
}
|