@massimo-cassandro/minimo 1.33.0 → 1.33.1
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/README.md +2 -1
- package/dev-tools/starter-kit/source_files/{CLAUDE-frontend.md → app/CLAUDE.md} +1 -1
- package/dev-tools/starter-kit/source_files/app/assets/api_htaccess +20 -0
- package/dev-tools/starter-kit/source_files/{layout-critical.css → app/css/layout.critical.css} +1 -1
- package/dev-tools/starter-kit/source_files/app/css/layout.css +0 -0
- package/dev-tools/starter-kit/source_files/app/index.js +1 -0
- package/dev-tools/starter-kit/source_files/root/webpack-config-modules/inline-critical-css.mjs +41 -0
- package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/purgecss-setup.mjs +1 -1
- package/dev-tools/starter-kit/{webpack.config.mjs → source_files/root/webpack.config.mjs} +50 -24
- package/dev-tools/starter-kit/starter-install.sh +141 -83
- package/dev-tools/stylelint-config/test/test.module.scss +9 -0
- package/package.json +1 -1
- package/snippets/php/iviewer.php +488 -0
- package/snippets/twig-symfony/ViewerController.php +549 -0
- package/src/custom-properties.css +29 -0
- package/src/minimo.css +3 -0
- package/src/utilities/dom-builder/dom-builder.js +9 -5
- package/src/web-components/json-table/json-table-component.js +387 -38
- package/src/web-components/json-table/json-table-component.module.css +190 -0
- package/src/web-components/json-table/json-table.minimo.tokens.mjs +195 -0
- package/src/web-components/json-table/readme.md +603 -82
- package/src/web-components/json-table/src/cell-content.js +136 -0
- package/src/web-components/json-table/src/content-utils.js +103 -0
- package/src/web-components/json-table/src/data-types.js +280 -0
- package/src/web-components/json-table/src/defaults.js +377 -58
- package/src/web-components/json-table/src/get-data.js +105 -10
- package/src/web-components/json-table/src/icons.js +80 -0
- package/src/web-components/json-table/src/info-section.js +85 -50
- package/src/web-components/json-table/src/main-builder.js +175 -52
- package/src/web-components/json-table/src/pagination.js +253 -0
- package/src/web-components/json-table/src/parse-cols.js +113 -0
- package/src/web-components/json-table/src/parse-rows.js +81 -0
- package/src/web-components/json-table/src/resolve-params.js +102 -32
- package/src/web-components/json-table/src/search.js +71 -0
- package/src/web-components/json-table/src/sorting.js +111 -0
- package/src/web-components/json-table/src/table-body.js +109 -0
- package/src/web-components/json-table/src/table-builder.js +152 -0
- package/src/web-components/json-table/src/table-tfoot.js +56 -0
- package/src/web-components/json-table/src/table-thead.js +183 -0
- package/src/web-components/json-table/src/update-info.js +43 -24
- package/src/web-components/s-datatable-component/{docs.md → readme.md} +5 -3
- package/src/web-components/s-datatable-component/s-datatable-component.js +1 -1
- package/types/global.d.ts +17 -3
- package/dev-tools/starter-kit/source_files/app_index.js +0 -1
- package/snippets/config-templates/_htaccess +0 -69
- package/snippets/config-templates/robots.txt +0 -5
- package/snippets/config-templates/rollup.config.mjs +0 -115
- /package/dev-tools/starter-kit/source_files/{_root_robots.txt → app/assets/robots.txt} +0 -0
- /package/dev-tools/starter-kit/source_files/{_root_htaccess → app/assets/root_htaccess} +0 -0
- /package/{src → dev-tools/starter-kit/source_files/app/css}/fonts.css +0 -0
- /package/dev-tools/starter-kit/source_files/{favicons-readme.md → app/favicons/favicons-readme.md} +0 -0
- /package/dev-tools/starter-kit/{webpack-template.ejs → source_files/app/tpl/index.ejs} +0 -0
- /package/dev-tools/starter-kit/source_files/{__project__.code-workspace → root/__project__.code-workspace} +0 -0
- /package/dev-tools/starter-kit/source_files/{_browserslistrc → root/_browserslistrc} +0 -0
- /package/dev-tools/starter-kit/source_files/{_editorconfig → root/_editorconfig} +0 -0
- /package/dev-tools/starter-kit/source_files/{_gitignore → root/_gitignore} +0 -0
- /package/dev-tools/starter-kit/source_files/{_prettierrc → root/_prettierrc} +0 -0
- /package/dev-tools/starter-kit/source_files/{eslint.config.mjs → root/eslint.config.mjs} +0 -0
- /package/dev-tools/starter-kit/source_files/{jsconfig.json → root/jsconfig.json} +0 -0
- /package/dev-tools/starter-kit/{package-tpl.json → source_files/root/package-tpl.json} +0 -0
- /package/dev-tools/starter-kit/source_files/{stylelint.config.mjs → root/stylelint.config.mjs} +0 -0
- /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/css-rules.mjs +0 -0
- /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/get-jsConfig-aliases.mjs +0 -0
- /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/mini-svg-data-uri-loader.cjs +0 -0
- /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/postcss.config.mjs +0 -0
- /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/purgecss-variables-safelist.mjs +0 -0
- /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/svg-rules.mjs +0 -0
- /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/svgo.config.mjs +0 -0
- /package/snippets/{config-templates/_github → _github}/dependabot.yml +0 -0
- /package/snippets/{error-pages/error-pages.js → error-pages.js} +0 -0
- /package/snippets/{config-templates/react → react}/offcanvas/offcanvas.jsx +0 -0
- /package/snippets/{config-templates/react → react}/offcanvas/offcanvas.module.scss +0 -0
- /package/snippets/{config-templates → root}/_hintrc.cjs +0 -0
- /package/snippets/{config-templates → root}/_npmignore +0 -0
- /package/snippets/{config-templates → root}/_npmrc +0 -0
- /package/snippets/{config-templates → root}/_stylelintignore +0 -0
- /package/snippets/{config-templates → root}/babel.config--react.json +0 -0
- /package/snippets/{config-templates → root}/babel.config--solidJS.json +0 -0
- /package/snippets/{ImgViewerController.php → twig-symfony/ImgViewerController.php} +0 -0
- /package/snippets/{UnsplashController.php → twig-symfony/UnsplashController.php} +0 -0
- /package/snippets/{config-templates → twig-symfony}/_env.local +0 -0
- /package/snippets/{error-pages → twig-symfony}/bundles/TwigBundle/Exception/error.html.twig +0 -0
- /package/snippets/{flash-messages.html.twig → twig-symfony/flash-messages.html.twig} +0 -0
- /package/snippets/{minimo-form-layout.html.twig → twig-symfony/minimo-form-layout.html.twig} +0 -0
package/README.md
CHANGED
|
@@ -9,9 +9,10 @@ npm i @massimo-cassandro/minimo
|
|
|
9
9
|
|
|
10
10
|
# optional:
|
|
11
11
|
npm i -D @massimo-cassandro/eslint-config
|
|
12
|
-
npm i -D @massimo-cassandro/stylelint-config
|
|
13
12
|
```
|
|
14
13
|
|
|
14
|
+
> Note: a stylelint config is bundled with minimo itself (no separate install needed) — see [dev-tools/stylelint-config/README.md](dev-tools/stylelint-config/README.md).
|
|
15
|
+
|
|
15
16
|
> Note: **minimo** is designed to be used with WebPack using the configuration you can find in the [starter-kit folder](./dev-tools/starter-kit/) of this repository. If changes are made (for example, to how SVG files are imported), things may not work as expected.
|
|
16
17
|
>
|
|
17
18
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
- Conferma la comprensione prima di agire su richieste ambigue
|
|
10
10
|
- Il progetto usa ES modules (import/export), evitare soluzioni che utilizzano commonJs
|
|
11
11
|
- In linea di massima non proporre soluzioni che richiedano modifiche alla parte back-end, se presente, a meno che non sia esplicitamente richiesto
|
|
12
|
-
- nella chat evitare neologismi come parsare, committare ecc., usare i termini corrispondenti in italiano o il termine originale in inglese dove non sia possibile un equivalente in italiano. Non coniugare mai secondo le regole dell'italiano verbi di altre lingue
|
|
12
|
+
- nella chat evitare neologismi come inlinare, parsare, committare ecc., usare i termini corrispondenti in italiano o il termine originale in inglese dove non sia possibile un equivalente in italiano. Non coniugare mai secondo le regole dell'italiano verbi di altre lingue
|
|
13
13
|
- nei commenti su più righe preferire `/* ... */` piuttosto che ripetere `//` ad igni inizio riga
|
|
14
14
|
- a meno che non sia esplicitamente richiesto di eseguire subito una modifica, NON ESEGUIRE MAI nulla autonomamente ma mostra sempre un piano d'azione prima di procedere
|
|
15
15
|
- nei commenti jsDoc aggiungere sempre dove possibile una sezione example che riepiloghi i vari parametri mostrando i valori di default
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Nega l'accesso diretto ai soli file di configurazione (contengono le
|
|
2
|
+
# credenziali OAuth). Gli altri file di questa cartella sono endpoint veri
|
|
3
|
+
# e propri (login.php, callback.php, whoami.php, ecc.) e devono restare
|
|
4
|
+
# raggiungibili normalmente: qui non c'è un "Require all denied" sull'intera
|
|
5
|
+
# cartella come quando cfg/ era isolata.
|
|
6
|
+
# I file restano comunque leggibili da PHP tramite require (accesso da
|
|
7
|
+
# filesystem, non passa da Apache), quindi l'app continua a funzionare.
|
|
8
|
+
|
|
9
|
+
<FilesMatch "^config(-template|-prod)?\.php$">
|
|
10
|
+
# Apache 2.4+ (praticamente tutti gli hosting attuali)
|
|
11
|
+
<IfModule mod_authz_core.c>
|
|
12
|
+
Require all denied
|
|
13
|
+
</IfModule>
|
|
14
|
+
|
|
15
|
+
# Fallback per Apache 2.2 (hosting più vecchi)
|
|
16
|
+
<IfModule !mod_authz_core.c>
|
|
17
|
+
Order deny,allow
|
|
18
|
+
Deny from all
|
|
19
|
+
</IfModule>
|
|
20
|
+
</FilesMatch>
|
package/dev-tools/starter-kit/source_files/{layout-critical.css → app/css/layout.critical.css}
RENAMED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Per ulteriori entry critical specifiche di pagina, copiare e rinominare.
|
|
4
4
|
|
|
5
5
|
Le entry con suffisso `.critical` generano asset destinati a essere
|
|
6
|
-
|
|
6
|
+
inseriti inline nei template html: devono restare AUTOSUFFICIENTI e minimi.
|
|
7
7
|
Il suffisso attiva l'istanza PurgeCSS dedicata con purge stretto, in dev
|
|
8
8
|
e in prod (vedi purgeCSSPluginCritical in webpack.config.mjs), e la regola
|
|
9
9
|
dedicata in css-rules.mjs.
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@css/index.css';
|
package/dev-tools/starter-kit/source_files/root/webpack-config-modules/inline-critical-css.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* plugins/inline-critical-css.mjs */
|
|
2
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
3
|
+
|
|
4
|
+
export class InlineCriticalCssPlugin {
|
|
5
|
+
constructor({ match }) {
|
|
6
|
+
this.match = match;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
apply(compiler) {
|
|
10
|
+
compiler.hooks.compilation.tap('InlineCriticalCssPlugin', (compilation) => {
|
|
11
|
+
HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tapAsync(
|
|
12
|
+
'InlineCriticalCssPlugin',
|
|
13
|
+
(data, callback) => {
|
|
14
|
+
const isTarget = (tag) =>
|
|
15
|
+
tag.tagName === 'link' && this.match(tag.attributes.href);
|
|
16
|
+
|
|
17
|
+
const linkTag = [...data.headTags, ...data.bodyTags].find(isTarget);
|
|
18
|
+
|
|
19
|
+
if (linkTag) {
|
|
20
|
+
const publicPath = compilation.outputOptions.publicPath || '';
|
|
21
|
+
const assetName = linkTag.attributes.href.replace(publicPath, '');
|
|
22
|
+
const source = compilation.assets[assetName]?.source();
|
|
23
|
+
|
|
24
|
+
if (source) {
|
|
25
|
+
const styleTag = {
|
|
26
|
+
tagName: 'style',
|
|
27
|
+
voidTag: false,
|
|
28
|
+
innerHTML: source,
|
|
29
|
+
attributes: {},
|
|
30
|
+
};
|
|
31
|
+
data.headTags = data.headTags.filter((t) => !isTarget(t)).concat(styleTag);
|
|
32
|
+
data.bodyTags = data.bodyTags.filter((t) => !isTarget(t));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
callback(null, data);
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -5,7 +5,7 @@ import { purgecssVariablesSafelist } from './purgecss-variables-safelist.mjs';
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
Istanzia i plugin PurgeCSS del progetto: un passaggio stretto sui css
|
|
8
|
-
`.critical` (
|
|
8
|
+
`.critical` (inline nei template, devono restare autosufficienti) e un
|
|
9
9
|
passaggio generale su tutti gli altri asset (il purge è idempotente: il
|
|
10
10
|
secondo passaggio sui critical non rimuove altro).
|
|
11
11
|
|
|
@@ -22,6 +22,8 @@ import { cssRules } from './webpack-config-modules/css-rules.mjs';
|
|
|
22
22
|
import { createPurgeCSSPlugins } from './webpack-config-modules/purgecss-setup.mjs';
|
|
23
23
|
import { getJsConfigAliases } from './webpack-config-modules/get-jsConfig-aliases.mjs';
|
|
24
24
|
import { svgRules } from './webpack-config-modules/svg-rules.mjs';
|
|
25
|
+
// import { InlineCriticalCssPlugin } from './webpack-config-modules/inline-critical-css.mjs';
|
|
26
|
+
|
|
25
27
|
|
|
26
28
|
// --- config ---
|
|
27
29
|
const __filename = fileURLToPath(import.meta.url)
|
|
@@ -30,10 +32,10 @@ const __filename = fileURLToPath(import.meta.url)
|
|
|
30
32
|
// Risolve un percorso a partire dalla root del progetto, che coincide con la dir
|
|
31
33
|
// di questo file solo se il frontend NON è in una sottodirectory (es. ./app):
|
|
32
34
|
// vengono provate entrambe le posizioni, in fallback la prima
|
|
33
|
-
const fromProjectRoot = (relPath) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
35
|
+
// const fromProjectRoot = (relPath) => {
|
|
36
|
+
// const candidates = ['./', '../'].map(p => path.resolve(__dirname, p, relPath));
|
|
37
|
+
// return candidates.find(p => fs.existsSync(p)) ?? candidates[0];
|
|
38
|
+
// };
|
|
37
39
|
|
|
38
40
|
const isDevelopment = process.env.NODE_ENV === 'development'
|
|
39
41
|
,devServerPort = [[port5700]]
|
|
@@ -60,11 +62,11 @@ const isDevelopment = process.env.NODE_ENV === 'development'
|
|
|
60
62
|
// NB: jsconfig.json va tenuto in questa stessa dir (gli alias sono risolti
|
|
61
63
|
// a partire dalla sua posizione)
|
|
62
64
|
,jsConfigAliases = getJsConfigAliases(path.resolve(__dirname, './jsconfig.json'))
|
|
63
|
-
,packageJson = JSON.parse(fs.readFileSync(fromProjectRoot('package.json'), 'utf-8'))
|
|
65
|
+
,packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf-8')) //JSON.parse(fs.readFileSync(fromProjectRoot('package.json'), 'utf-8'))
|
|
64
66
|
|
|
65
67
|
// path del pacchetto minimo (il suo js genera markup con classi proprie e il
|
|
66
68
|
// suo css dichiara custom properties: entrambi vanno visti da PurgeCSS)
|
|
67
|
-
,minimo_path = fromProjectRoot('node_modules/@massimo-cassandro/minimo')
|
|
69
|
+
,minimo_path = './node_modules/@massimo-cassandro/minimo' // fromProjectRoot('node_modules/@massimo-cassandro/minimo')
|
|
68
70
|
|
|
69
71
|
,usePurgeCss = true // false per disattivare PurgeCSS (debug rapido di problemi legati al purge)
|
|
70
72
|
,purgeCSSOptions = {
|
|
@@ -78,7 +80,7 @@ const isDevelopment = process.env.NODE_ENV === 'development'
|
|
|
78
80
|
// test del cacheGroup `shared` (splitChunks): i css restano SEMPRE FUORI dal
|
|
79
81
|
// chunk condiviso e nel chunk della entry che li importa, così ogni asset css
|
|
80
82
|
// resta autosufficiente (`variables: true` funziona per singolo asset, e i
|
|
81
|
-
// critical css
|
|
83
|
+
// critical css inline nei template devono restare autosufficienti). I
|
|
82
84
|
// template (twig/altro) linkano solo il css della propria entry (e gli
|
|
83
85
|
// eventuali `.critical.css`), MAI uno shared.css: se i css finissero nel
|
|
84
86
|
// chunk condiviso, quella parte di stili sparirebbe silenziosamente dalla
|
|
@@ -120,24 +122,41 @@ const shared_chunk_paths = (module) => {
|
|
|
120
122
|
const CopyWebpackPluginPatterns = [
|
|
121
123
|
|
|
122
124
|
// {
|
|
123
|
-
// from: '
|
|
124
|
-
// to: '
|
|
125
|
-
// context: './source/path/', // viene rimosso nella copia
|
|
125
|
+
// from: 'app/api',
|
|
126
|
+
// to: 'api',
|
|
126
127
|
// globOptions: {
|
|
127
128
|
// dot: true,
|
|
128
129
|
// gitignore: true,
|
|
129
|
-
// ignore: [
|
|
130
|
+
// ignore: [
|
|
131
|
+
// '**/.DS_Store',
|
|
132
|
+
// // config.php e config-prod.php sono
|
|
133
|
+
// // gestiti a parte nei pattern successivi (config.php è sempre
|
|
134
|
+
// // scritto a mano per ambiente, mai copiato dalla build)
|
|
135
|
+
// // '**/config.php',
|
|
136
|
+
// // '**/config-prod.php',
|
|
137
|
+
// ]
|
|
130
138
|
// }
|
|
131
139
|
// },
|
|
132
140
|
// {
|
|
133
|
-
// from: 'app/php',
|
|
134
|
-
// to: 'php'
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
// }
|
|
141
|
+
// from: 'app/api/config-prod.php',
|
|
142
|
+
// to: 'api/config.php'
|
|
143
|
+
// },
|
|
144
|
+
// {
|
|
145
|
+
// from: './app/assets/root_htaccess',
|
|
146
|
+
// to: '.htaccess',
|
|
147
|
+
// toType: 'file'
|
|
148
|
+
// },
|
|
149
|
+
// {
|
|
150
|
+
// from: './app/assets/robots.txt',
|
|
151
|
+
// to: 'robots.txt',
|
|
152
|
+
// toType: 'file'
|
|
153
|
+
// },
|
|
154
|
+
// {
|
|
155
|
+
// from: './app/assets/api_htaccess',
|
|
156
|
+
// to: 'api/.htaccess',
|
|
157
|
+
// toType: 'file',
|
|
158
|
+
// // context: 'app/api'
|
|
159
|
+
// },
|
|
141
160
|
];
|
|
142
161
|
|
|
143
162
|
// =>> PurgeCSS
|
|
@@ -155,12 +174,13 @@ const CopyWebpackPluginPatterns = [
|
|
|
155
174
|
// =>> entries
|
|
156
175
|
// NB: percorsi dalla root del progetto
|
|
157
176
|
const entries = {
|
|
158
|
-
'
|
|
177
|
+
'index': './app/index.js',
|
|
159
178
|
|
|
160
|
-
// css critici
|
|
179
|
+
// css critici da includere inline nei template html: il suffisso `.critical` nel nome
|
|
161
180
|
// della entry attiva l'istanza PurgeCSS dedicata con purge stretto
|
|
162
181
|
// (vedi purgecss-setup.mjs) e la regola dedicata in css-rules.mjs
|
|
163
|
-
|
|
182
|
+
'layout.critical': './app/css/layout.critical.css'
|
|
183
|
+
|
|
164
184
|
};
|
|
165
185
|
|
|
166
186
|
|
|
@@ -195,7 +215,7 @@ const config = {
|
|
|
195
215
|
path: output_dir,
|
|
196
216
|
filename: '[name].[contenthash].js',
|
|
197
217
|
publicPath: '/',
|
|
198
|
-
// publicPath: isDevelopment? '/' : './', //
|
|
218
|
+
// publicPath: isDevelopment? '/' : './', // nel caso in cui l'output di produzione non sia sulla root
|
|
199
219
|
clean: !isDevelopment
|
|
200
220
|
},
|
|
201
221
|
|
|
@@ -350,6 +370,12 @@ const config = {
|
|
|
350
370
|
ignoreOrder: true
|
|
351
371
|
}),
|
|
352
372
|
|
|
373
|
+
// =>> plugins: InlineCriticalCssPlugin (solo prod)
|
|
374
|
+
// ...(isDevelopment
|
|
375
|
+
// ? []
|
|
376
|
+
// : [new InlineCriticalCssPlugin({ match: (href) => href?.includes('.critical') })]
|
|
377
|
+
// ),
|
|
378
|
+
|
|
353
379
|
// =>> plugins: HtmlWebpackPlugin (manifest)
|
|
354
380
|
new HtmlWebpackPlugin({
|
|
355
381
|
filename: 'manifest.webmanifest',
|
|
@@ -425,7 +451,7 @@ const config = {
|
|
|
425
451
|
|
|
426
452
|
},
|
|
427
453
|
raw: true,
|
|
428
|
-
// niente banner nei critical css: vengono
|
|
454
|
+
// niente banner nei critical css: vengono inseriti inline nei template html
|
|
429
455
|
exclude: /\.critical/ // chunk name
|
|
430
456
|
}),
|
|
431
457
|
|
|
@@ -2,15 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
# IMPORTANTE: questo script è idempotente e deve restare tale.
|
|
4
4
|
# Può essere rilanciato più volte sullo stesso progetto (anche via `npx starter-kit`
|
|
5
|
-
# per aggiornare un setup esistente) senza sovrascrivere nulla né creare duplicati
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
5
|
+
# per aggiornare un setup esistente) senza sovrascrivere nulla né creare duplicati.
|
|
6
|
+
# Per i singoli file installati sulla root del progetto e dentro
|
|
7
|
+
# ./webpack-config-modules: se il contenuto esistente è identico al sorgente la
|
|
8
|
+
# copia viene saltata; se è diverso e non esiste ancora un OLD- corrispondente,
|
|
9
|
+
# il file esistente viene rinominato con prefisso OLD- (preservato da quel
|
|
10
|
+
# momento in poi, non viene più toccato nelle esecuzioni successive) e il nuovo
|
|
11
|
+
# file prende il nome originale; se l'OLD- corrispondente esiste già, viene
|
|
12
|
+
# invece sovrascritto direttamente il file "nuovo", senza aggiungere ulteriori
|
|
13
|
+
# prefissi. Stessa logica, a livello di intera cartella (senza diff sui
|
|
14
|
+
# singoli file contenuti al suo interno prima della prima installazione), per
|
|
15
|
+
# ./webpack-config-modules.
|
|
16
|
+
# ./app segue invece una logica più semplice: viene rinominata per intero in
|
|
17
|
+
# OLD-app solo la prima volta che esiste già (preservata da quel momento in
|
|
18
|
+
# poi, mai più toccata); i file al suo interno vengono sempre sovrascritti
|
|
19
|
+
# senza controllo né backup individuale (force_cat), dato che l'intera
|
|
20
|
+
# cartella precedente resta comunque disponibile in OLD-app.
|
|
14
21
|
# Ogni modifica futura deve conservare questa proprietà.
|
|
15
22
|
|
|
16
23
|
RED='\033[0;31m'
|
|
@@ -93,8 +100,6 @@ echo "BASE_URL: ${BASE_URL}"
|
|
|
93
100
|
SOURCE_FILES_DIR="${BASE_URL}/source_files"
|
|
94
101
|
|
|
95
102
|
# webpack
|
|
96
|
-
WEBPACK_CONFIG_SOURCE_PATH="$BASE_URL"
|
|
97
|
-
WEBPACK_MODULES_SOURCE_PATH="${BASE_URL}/webpack-config-modules"
|
|
98
103
|
WEBPACK_MODULES_INSTALL_PATH="./webpack-config-modules"
|
|
99
104
|
|
|
100
105
|
# protezione contro la sovrascrittura
|
|
@@ -147,11 +152,83 @@ safe_cat_with_ports() {
|
|
|
147
152
|
return $rc
|
|
148
153
|
}
|
|
149
154
|
|
|
155
|
+
# A differenza di safe_cat, sovrascrive sempre senza confrontare né
|
|
156
|
+
# backuppare (nessun OLD- a livello di singolo file). Usata per i file
|
|
157
|
+
# installati dentro FRONTEND_INSTALL_PATH (./app), la cui idempotenza è già
|
|
158
|
+
# garantita a livello di intera cartella (OLD-app, vedi più sotto): non ha
|
|
159
|
+
# senso ripetere il controllo su ogni singolo file al suo interno.
|
|
160
|
+
force_cat() {
|
|
161
|
+
local src="$1"
|
|
162
|
+
local dest="$2"
|
|
163
|
+
if [ ! -f "$src" ]; then
|
|
164
|
+
echo -e "${RED}Sorgente mancante: $src${NC}"
|
|
165
|
+
return 1
|
|
166
|
+
fi
|
|
167
|
+
cat "$src" >| "$dest"
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
# Copia ricorsivamente tutti i file di una struttura sorgente (source_files/root
|
|
171
|
+
# o source_files/app) in una destinazione, preservando la struttura delle
|
|
172
|
+
# sotto-cartelle così com'è in source_files: aggiungere, spostare o rinominare
|
|
173
|
+
# file lì non richiede modifiche a questo script.
|
|
174
|
+
# Il terzo argomento (opzionale) è il nome di una funzione di rename invocata
|
|
175
|
+
# su ogni singolo basename, per i casi in cui il nome del file sorgente non
|
|
176
|
+
# coincide con quello di destinazione (vedi rename_root_file).
|
|
177
|
+
# Il quarto argomento (opzionale, default: safe_cat_with_ports) è la funzione
|
|
178
|
+
# di copia da usare per ogni file: safe_cat_with_ports confronta e backuppa
|
|
179
|
+
# il singolo file (sostituzione porte no-op se non contiene placeholder);
|
|
180
|
+
# force_cat sovrascrive sempre senza controlli (vedi sopra, usata per ./app).
|
|
181
|
+
install_tree() {
|
|
182
|
+
local src_root="$1"
|
|
183
|
+
local dest_root="$2"
|
|
184
|
+
local rename_fn="$3"
|
|
185
|
+
local copy_fn="${4:-safe_cat_with_ports}"
|
|
186
|
+
local file rel dir base new_base dest
|
|
187
|
+
while IFS= read -r file; do
|
|
188
|
+
rel="${file#"$src_root"/}"
|
|
189
|
+
dir="$(dirname "$rel")"
|
|
190
|
+
base="$(basename "$rel")"
|
|
191
|
+
if [ -n "$rename_fn" ]; then
|
|
192
|
+
new_base="$("$rename_fn" "$base")"
|
|
193
|
+
else
|
|
194
|
+
new_base="$base"
|
|
195
|
+
fi
|
|
196
|
+
if [ "$dir" = "." ]; then
|
|
197
|
+
dest="${dest_root}/${new_base}"
|
|
198
|
+
else
|
|
199
|
+
mkdir -p "${dest_root}/${dir}"
|
|
200
|
+
dest="${dest_root}/${dir}/${new_base}"
|
|
201
|
+
fi
|
|
202
|
+
"$copy_fn" "$file" "$dest"
|
|
203
|
+
done < <(find "$src_root" -type f)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
# Rename applicato ai file di source_files/root/ in fase di copia:
|
|
207
|
+
# - prefisso singolo underscore -> dotfile (es. _gitignore -> .gitignore);
|
|
208
|
+
# il doppio underscore (__project__.code-workspace) non viene toccato,
|
|
209
|
+
# il nome resta invariato
|
|
210
|
+
# - suffisso -tpl prima dell'estensione -> rimosso (es. package-tpl.json ->
|
|
211
|
+
# package.json), usato per i file template che altrimenti confliggerebbero
|
|
212
|
+
# con l'omonimo file dello starter-kit stesso
|
|
213
|
+
rename_root_file() {
|
|
214
|
+
local name="$1"
|
|
215
|
+
if [[ "$name" == _* && "$name" != __* ]]; then
|
|
216
|
+
echo ".${name#_}"
|
|
217
|
+
return
|
|
218
|
+
fi
|
|
219
|
+
if [[ "$name" == *-tpl.* ]]; then
|
|
220
|
+
echo "${name/-tpl./.}"
|
|
221
|
+
return
|
|
222
|
+
fi
|
|
223
|
+
echo "$name"
|
|
224
|
+
}
|
|
225
|
+
|
|
150
226
|
FRONTEND_INSTALL_PATH="./app"
|
|
151
227
|
# se la cartella esiste già: la prima volta viene rinominata per intero in
|
|
152
228
|
# OLD-app (preservata, mai più toccata); se OLD-app esiste già, la cartella
|
|
153
|
-
# esistente non viene rinominata
|
|
154
|
-
#
|
|
229
|
+
# esistente non viene rinominata. In entrambi i casi i file al suo interno
|
|
230
|
+
# vengono poi sempre sovrascritti senza controlli individuali (force_cat):
|
|
231
|
+
# l'idempotenza è garantita a livello di intera cartella, non di singolo file.
|
|
155
232
|
if [ -d "$FRONTEND_INSTALL_PATH" ]; then
|
|
156
233
|
OLD_FRONTEND_INSTALL_PATH="$(dirname "$FRONTEND_INSTALL_PATH")/OLD-$(basename "$FRONTEND_INSTALL_PATH")"
|
|
157
234
|
if [ ! -e "$OLD_FRONTEND_INSTALL_PATH" ]; then
|
|
@@ -160,50 +237,6 @@ if [ -d "$FRONTEND_INSTALL_PATH" ]; then
|
|
|
160
237
|
fi
|
|
161
238
|
|
|
162
239
|
echo -e "${GREEN}Files will be installed in: '${FRONTEND_INSTALL_PATH}'${NC}"
|
|
163
|
-
mkdir -p "${FRONTEND_INSTALL_PATH}"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
echo -e "${GREEN}...ROOT FILES${NC}"
|
|
168
|
-
safe_cat_with_ports "${BASE_URL}/package-tpl.json" package.json
|
|
169
|
-
safe_cat_with_ports "${WEBPACK_CONFIG_SOURCE_PATH}/webpack.config.mjs" webpack.config.mjs
|
|
170
|
-
|
|
171
|
-
safe_cat "${SOURCE_FILES_DIR}/_gitignore" .gitignore
|
|
172
|
-
safe_cat "${SOURCE_FILES_DIR}/_browserslistrc" .browserslistrc
|
|
173
|
-
safe_cat "${SOURCE_FILES_DIR}/_editorconfig" .editorconfig
|
|
174
|
-
safe_cat "${SOURCE_FILES_DIR}/_prettierrc" .prettierrc
|
|
175
|
-
safe_cat "${SOURCE_FILES_DIR}/jsconfig.json" jsconfig.json
|
|
176
|
-
safe_cat "${SOURCE_FILES_DIR}/__project__.code-workspace" __project__.code-workspace
|
|
177
|
-
safe_cat "${SOURCE_FILES_DIR}/eslint.config.mjs" eslint.config.mjs
|
|
178
|
-
safe_cat "${SOURCE_FILES_DIR}/stylelint.config.mjs" stylelint.config.mjs
|
|
179
|
-
|
|
180
|
-
echo -e "${GREEN}...APP FILES${NC}"
|
|
181
|
-
safe_cat "${SOURCE_FILES_DIR}/_root_htaccess" "${FRONTEND_INSTALL_PATH}/_root_htaccess"
|
|
182
|
-
safe_cat "${SOURCE_FILES_DIR}/_root_robots.txt" "${FRONTEND_INSTALL_PATH}/_root_robots.txt"
|
|
183
|
-
safe_cat "${SOURCE_FILES_DIR}/CLAUDE-frontend.md" "${FRONTEND_INSTALL_PATH}/CLAUDE.md"
|
|
184
|
-
safe_cat "${WEBPACK_CONFIG_SOURCE_PATH}/webpack-template.ejs" "${FRONTEND_INSTALL_PATH}/tpl/index.ejs"
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
echo -e "${GREEN}..WEBPACK CONFIG MODULES${NC}"
|
|
188
|
-
# se la cartella esiste già: la prima volta viene rinominata per intero in
|
|
189
|
-
# OLD-webpack-config-modules (preservata, mai più toccata); se l'OLD-
|
|
190
|
-
# corrispondente esiste già, la cartella esistente non viene rinominata e i
|
|
191
|
-
# file al suo interno vengono gestiti singolarmente dalla stessa logica di
|
|
192
|
-
# safe_cat.
|
|
193
|
-
if [ -d "$WEBPACK_MODULES_INSTALL_PATH" ]; then
|
|
194
|
-
OLD_WEBPACK_MODULES_INSTALL_PATH="$(dirname "$WEBPACK_MODULES_INSTALL_PATH")/OLD-$(basename "$WEBPACK_MODULES_INSTALL_PATH")"
|
|
195
|
-
if [ ! -e "$OLD_WEBPACK_MODULES_INSTALL_PATH" ]; then
|
|
196
|
-
mv "$WEBPACK_MODULES_INSTALL_PATH" "$OLD_WEBPACK_MODULES_INSTALL_PATH"
|
|
197
|
-
fi
|
|
198
|
-
fi
|
|
199
|
-
|
|
200
|
-
mkdir -p "$WEBPACK_MODULES_INSTALL_PATH"
|
|
201
|
-
|
|
202
|
-
# copia tutti i file presenti in webpack-modules,
|
|
203
|
-
for FILE in "${WEBPACK_MODULES_SOURCE_PATH}"/*; do
|
|
204
|
-
[ -f "$FILE" ] || continue
|
|
205
|
-
safe_cat "$FILE" "${WEBPACK_MODULES_INSTALL_PATH}/$(basename "$FILE")"
|
|
206
|
-
done
|
|
207
240
|
|
|
208
241
|
|
|
209
242
|
echo -e "\n${GREEN}...NODE MODULES${NC}"
|
|
@@ -271,6 +304,9 @@ done
|
|
|
271
304
|
|
|
272
305
|
echo -e "\n${GREEN}...creating default folders${NC}"
|
|
273
306
|
mkdir -p \
|
|
307
|
+
"_private" \
|
|
308
|
+
"${FRONTEND_INSTALL_PATH}" \
|
|
309
|
+
"${FRONTEND_INSTALL_PATH}/assets" \
|
|
274
310
|
"${FRONTEND_INSTALL_PATH}/src" \
|
|
275
311
|
"${FRONTEND_INSTALL_PATH}/css" \
|
|
276
312
|
"${FRONTEND_INSTALL_PATH}/tpl" \
|
|
@@ -280,44 +316,66 @@ mkdir -p \
|
|
|
280
316
|
"${FRONTEND_INSTALL_PATH}/error-pages"
|
|
281
317
|
|
|
282
318
|
|
|
283
|
-
echo -e "${GREEN}...MINIMO FILES${NC}"
|
|
284
|
-
# Sorgenti di minimo da copiare nel progetto: si usa il pacchetto appena
|
|
285
|
-
# installato in node_modules (stessa versione che userà il progetto)
|
|
286
|
-
MINIMO_PKG_DIR=./node_modules/@massimo-cassandro/minimo
|
|
287
|
-
|
|
288
|
-
safe_cat "${MINIMO_PKG_DIR}/src/custom-properties.css" "${FRONTEND_INSTALL_PATH}/css/custom-properties.css"
|
|
289
|
-
safe_cat "${MINIMO_PKG_DIR}/src/custom-media.css" "${FRONTEND_INSTALL_PATH}/css/custom-media.css"
|
|
290
|
-
safe_cat "${MINIMO_PKG_DIR}/src/fonts.css" "${FRONTEND_INSTALL_PATH}/css/fonts.css"
|
|
291
|
-
|
|
292
|
-
# config di build-tokens: collocato accanto al css generato (custom-properties.css).
|
|
293
|
-
safe_cat "${MINIMO_PKG_DIR}/design-tokens/tokens-config-sample.mjs" "${FRONTEND_INSTALL_PATH}/css/tokens-config.mjs"
|
|
294
|
-
|
|
295
|
-
# entry css principale del progetto: copia diretta di minimo.css, rinominato
|
|
296
|
-
# index.css e collocato sulla root di installazione (non in /src)
|
|
297
|
-
safe_cat "${MINIMO_PKG_DIR}/src/minimo.css" "${FRONTEND_INSTALL_PATH}/index.css"
|
|
298
319
|
|
|
299
|
-
# favicons: config di default per `npx create-favicons`
|
|
300
|
-
safe_cat "${MINIMO_PKG_DIR}/dev-tools/create-favicons/src/default-params.mjs" "${FRONTEND_INSTALL_PATH}/favicons/create-favicons-cfg.mjs"
|
|
301
|
-
# favicons: istruzioni d'uso di `npx create-favicons`
|
|
302
|
-
safe_cat "${SOURCE_FILES_DIR}/favicons-readme.md" "${FRONTEND_INSTALL_PATH}/favicons/readme.md"
|
|
303
320
|
|
|
321
|
+
echo -e "${GREEN}...FILES${NC}"
|
|
304
322
|
|
|
305
|
-
|
|
306
|
-
#
|
|
307
|
-
|
|
323
|
+
echo -e "${DIM}...webpack config modules${NC}"
|
|
324
|
+
# se la cartella esiste già: la prima volta viene rinominata per intero in
|
|
325
|
+
# OLD-webpack-config-modules (preservata, mai più toccata); se l'OLD-
|
|
326
|
+
# corrispondente esiste già, la cartella esistente non viene rinominata e i
|
|
327
|
+
# file al suo interno vengono gestiti singolarmente dalla stessa logica di
|
|
328
|
+
# safe_cat (via install_tree, più sotto).
|
|
329
|
+
if [ -d "$WEBPACK_MODULES_INSTALL_PATH" ]; then
|
|
330
|
+
OLD_WEBPACK_MODULES_INSTALL_PATH="$(dirname "$WEBPACK_MODULES_INSTALL_PATH")/OLD-$(basename "$WEBPACK_MODULES_INSTALL_PATH")"
|
|
331
|
+
if [ ! -e "$OLD_WEBPACK_MODULES_INSTALL_PATH" ]; then
|
|
332
|
+
mv "$WEBPACK_MODULES_INSTALL_PATH" "$OLD_WEBPACK_MODULES_INSTALL_PATH"
|
|
333
|
+
fi
|
|
334
|
+
fi
|
|
308
335
|
|
|
309
|
-
|
|
310
|
-
safe_cat "${SOURCE_FILES_DIR}/layout-critical.css" "${FRONTEND_INSTALL_PATH}/css/layout-critical.css"
|
|
336
|
+
mkdir -p "$WEBPACK_MODULES_INSTALL_PATH"
|
|
311
337
|
|
|
338
|
+
# copia tutti i file di source_files/root/ nella root del progetto (inclusa
|
|
339
|
+
# webpack-config-modules/, gestita sopra a livello di cartella) e tutti i
|
|
340
|
+
# file di source_files/app/ dentro FRONTEND_INSTALL_PATH: struttura e nomi
|
|
341
|
+
# di destinazione sono già quelli definiti in source_files (per root/ con
|
|
342
|
+
# l'unica eccezione del rename dei dotfile e dei template "-tpl", vedi
|
|
343
|
+
# rename_root_file), quindi aggiungere/spostare/rinominare file lì non
|
|
344
|
+
# richiede modifiche a questo script. Per app/ si usa force_cat (nessun
|
|
345
|
+
# controllo/backup per singolo file, vedi commento su FRONTEND_INSTALL_PATH).
|
|
346
|
+
echo -e "${DIM}...root${NC}"
|
|
347
|
+
install_tree "${SOURCE_FILES_DIR}/root" "." rename_root_file
|
|
348
|
+
echo -e "${DIM}...app${NC}"
|
|
349
|
+
install_tree "${SOURCE_FILES_DIR}/app" "${FRONTEND_INSTALL_PATH}" "" force_cat
|
|
312
350
|
|
|
313
351
|
# copia tutti i file presenti in ${SOURCE_FILES_DIR}/_private,
|
|
314
|
-
echo -e "${
|
|
315
|
-
mkdir -p "_private"
|
|
352
|
+
echo -e "${DIM}..._private${NC}"
|
|
316
353
|
for FILE in "${SOURCE_FILES_DIR}/_private"/*; do
|
|
317
354
|
[ -f "$FILE" ] || continue
|
|
318
355
|
safe_cat_with_ports "$FILE" "_private/$(basename "$FILE")"
|
|
319
356
|
done
|
|
320
357
|
|
|
358
|
+
#----------------------------------------------
|
|
359
|
+
# copia altri file dai sorgenti minimo
|
|
360
|
+
#----------------------------------------------
|
|
361
|
+
# Sorgenti di minimo da copiare nel progetto: si usa il pacchetto appena
|
|
362
|
+
# installato in node_modules (stessa versione che userà il progetto)
|
|
363
|
+
MINIMO_PKG_DIR=./node_modules/@massimo-cassandro/minimo
|
|
364
|
+
|
|
365
|
+
force_cat "${MINIMO_PKG_DIR}/src/custom-properties.css" "${FRONTEND_INSTALL_PATH}/css/custom-properties.css"
|
|
366
|
+
force_cat "${MINIMO_PKG_DIR}/src/custom-media.css" "${FRONTEND_INSTALL_PATH}/css/custom-media.css"
|
|
367
|
+
|
|
368
|
+
# entry css principale del progetto: copia diretta di minimo.css, rinominato
|
|
369
|
+
force_cat "${MINIMO_PKG_DIR}/src/minimo.css" "${FRONTEND_INSTALL_PATH}/css/index.css"
|
|
370
|
+
|
|
371
|
+
# config di build-tokens: collocato accanto al css generato (custom-properties.css).
|
|
372
|
+
force_cat "${MINIMO_PKG_DIR}/design-tokens/tokens-config-sample.mjs" "${FRONTEND_INSTALL_PATH}/css/tokens-config.mjs"
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
# favicons: config di default per `npx create-favicons`
|
|
377
|
+
force_cat "${MINIMO_PKG_DIR}/dev-tools/create-favicons/src/default-params.mjs" "${FRONTEND_INSTALL_PATH}/favicons/create-favicons-cfg.mjs"
|
|
378
|
+
|
|
321
379
|
|
|
322
380
|
if [ ${#selectedOptionalPkgs[@]} -gt 0 ]; then
|
|
323
381
|
echo -e "\n${YELLOW}Pacchetti opzionali installati:${NC}"
|