chokibasic 1.2.3 → 2.0.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/index.d.ts CHANGED
@@ -1,137 +1,190 @@
1
- declare namespace chokibasic {
2
- // --- NOUVEAUX TYPES POUR buildConf ---
3
-
4
- /**
5
- * Callback pour buildConf.
6
- * Reçoit le contenu brut (Buffer) et le chemin relatif du fichier.
7
- * Doit retourner la nouvelle valeur (string, objet, etc.) qui remplacera le chemin dans le JSON final.
8
- */
9
- export type BuildConfCallback = (content: Buffer, relPath: string) => any | Promise<any>;
10
-
11
- /**
12
- * Dictionnaire de patterns globaux associés à des callbacks de transformation.
13
- * Exemple: { "** / *.mid": (buf) => processMidi(buf) }
14
- */
15
- export interface BuildConfMatchers {
16
- [glob: string]: BuildConfCallback;
17
- }
18
-
19
- // --- TYPES EXISTANTS ---
20
-
21
- export type GlobPattern = string;
22
-
23
- export type IgnoreMatcher =
24
- | string
25
- | RegExp
26
- | ((relPosixPath: string) => boolean);
27
-
28
- export type WatchEventType = "add" | "change" | "unlink" | (string & {});
29
-
30
- export interface WatchEvent {
31
- type: WatchEventType;
32
- file: string;
33
- }
34
-
35
- export interface WatchRuleContext {
36
- rule: WatchRule;
37
- }
38
-
39
- export interface WatchRule {
40
- name?: string;
41
- patterns: GlobPattern | GlobPattern[];
42
- ignored?: IgnoreMatcher[];
43
- debounceMs?: number;
44
- callback: (events: WatchEvent[], ctx: WatchRuleContext) => void | Promise<void>;
45
- }
46
-
47
- export interface AwaitWriteFinishOptions {
48
- stabilityThreshold?: number;
49
- pollInterval?: number;
50
- }
51
-
52
- export interface CreateWatchersOptions {
53
- cwd?: string;
54
- globalIgnored?: string[];
55
- ignoreInitial?: boolean;
56
- awaitWriteFinish?: boolean | AwaitWriteFinishOptions;
57
- usePolling?: boolean;
58
- interval?: number;
59
- binaryInterval?: number;
60
- debug?: boolean;
61
- [key: string]: unknown;
62
- }
63
-
64
- export interface WatchersController {
65
- close: () => Promise<void>;
66
- }
67
-
68
- export interface ExportDistStats {
69
- copied: number;
70
- skipped: number;
71
- }
72
-
73
- export interface ExportDistOptions {
74
- ignore?: string[];
75
- include?: string[];
76
- debug?: boolean;
77
- filter?: (relPath: string) => boolean;
78
- }
79
-
80
- export type BuildJSOptions = Parameters<typeof import("esbuild").build>[0];
81
- export type BuildCSSOptions = NonNullable<Parameters<typeof import("sass").compile>[1]>;
82
-
83
- // --- FONCTIONS EXPORTÉES ---
84
-
85
- /**
86
- * Transforme un fichier YAML en JSON en appliquant des transformations sur les fichiers référencés.
87
- * @param src Chemin vers le fichier source YAML.
88
- * @param dst Chemin vers le fichier de destination JSON.
89
- * @param matchers Dictionnaire de patterns et callbacks de transformation.
90
- */
91
- export function buildConf(
92
- src: string,
93
- dst: string,
94
- matchers?: BuildConfMatchers
95
- ): Promise<void>;
96
-
97
- export function createWatchers(
98
- rules: WatchRule[],
99
- options?: CreateWatchersOptions
100
- ): WatchersController;
101
-
102
- export function exportDist(
103
- src: string,
104
- dist: string,
105
- banner?: string | null,
106
- options?: ExportDistOptions
107
- ): Promise<ExportDistStats>;
108
-
109
- export function buildCSS(
110
- inputScss: string,
111
- outCssMin: string,
112
- options?: BuildCSSOptions
113
- ): Promise<void>;
114
-
115
- export function buildJS(
116
- entry: string,
117
- outfile: string,
118
- options?: BuildJSOptions
119
- ): Promise<void>;
120
-
121
- export function buildPHP(file: string): Promise<void>;
122
-
123
- export function buildSitemap(file: string): Promise<void>;
1
+ import type { BuildOptions } from "esbuild";
2
+ import type { Options as SassOptions } from "sass";
3
+
4
+ // ─── buildConf ────────────────────────────────────────────────────────────────
5
+
6
+ /**
7
+ * Callback pour buildConf.
8
+ * Reçoit le contenu brut (Buffer) et le chemin relatif du fichier.
9
+ * Doit retourner la nouvelle valeur (string, objet, etc.) qui remplacera
10
+ * le chemin dans le JSON final.
11
+ */
12
+ export type BuildConfCallback = (content: Buffer, relPath: string) => any | Promise<any>;
13
+
14
+ /**
15
+ * Dictionnaire de patterns globaux associés à des callbacks de transformation.
16
+ * Exemple : { "**\/*.mid": (buf) => processMidi(buf) }
17
+ */
18
+ export interface BuildConfMatchers {
19
+ [glob: string]: BuildConfCallback;
124
20
  }
125
21
 
126
- declare const chokibasic: {
127
- buildConf: typeof chokibasic.buildConf; // Ajouté ici aussi
128
- createWatchers: typeof chokibasic.createWatchers;
129
- exportDist: typeof chokibasic.exportDist;
130
- buildCSS: typeof chokibasic.buildCSS;
131
- buildJS: typeof chokibasic.buildJS;
132
- buildPHP: typeof chokibasic.buildPHP;
133
- buildSitemap: typeof chokibasic.buildSitemap;
134
- };
135
-
136
- export = chokibasic;
137
- export as namespace chokibasic;
22
+ /**
23
+ * Transforme un fichier YAML en JSON en appliquant des transformations
24
+ * sur les fichiers référencés dans les valeurs.
25
+ * Les tokens __VERSION__ et __DATE__ sont remplacés automatiquement.
26
+ *
27
+ * @param src Chemin vers le fichier source YAML.
28
+ * @param dst Chemin vers le fichier de destination JSON.
29
+ * @param matchers Dictionnaire de patterns et callbacks de transformation.
30
+ */
31
+ export function buildConf(
32
+ src: string,
33
+ dst: string,
34
+ matchers?: BuildConfMatchers
35
+ ): Promise<void>;
36
+
37
+ // ─── buildCSS ─────────────────────────────────────────────────────────────────
38
+
39
+ export type BuildCSSOptions = SassOptions<"sync">;
40
+
41
+ /**
42
+ * Compile un fichier SCSS en CSS minifié via Sass + csso.
43
+ * Si `options.style === "expanded"`, csso est ignoré et le CSS est écrit tel quel.
44
+ *
45
+ * @param inputScss Chemin vers le fichier SCSS source.
46
+ * @param outCssMin Chemin vers le fichier CSS de sortie.
47
+ * @param options Options Sass (style, loadPaths, sourceMap, …).
48
+ */
49
+ export function buildCSS(
50
+ inputScss: string,
51
+ outCssMin: string,
52
+ options?: BuildCSSOptions
53
+ ): Promise<void>;
54
+
55
+ // ─── buildJS ──────────────────────────────────────────────────────────────────
56
+
57
+ export type BuildJSOptions = BuildOptions;
58
+
59
+ /**
60
+ * Bundle et minifie un fichier JavaScript via esbuild.
61
+ *
62
+ * @param entry Chemin vers le fichier d'entrée.
63
+ * @param outfile Chemin vers le fichier de sortie.
64
+ * @param options Options esbuild (target, format, loader, plugins, …).
65
+ */
66
+ export function buildJS(
67
+ entry: string,
68
+ outfile: string,
69
+ options?: BuildJSOptions
70
+ ): Promise<void>;
71
+
72
+ // ─── buildPHP / buildSitemap ──────────────────────────────────────────────────
73
+
74
+ /**
75
+ * Génère du HTML à partir d'un fichier PHP via pxpros.
76
+ *
77
+ * @param file Chemin vers le fichier PHP source.
78
+ */
79
+ export function buildPHP(file: string): Promise<void>;
80
+
81
+ /**
82
+ * Génère un sitemap XML via pxpros.
83
+ *
84
+ * @param file Chemin vers le fichier de configuration du sitemap.
85
+ */
86
+ export function buildSitemap(file: string): Promise<void>;
87
+
88
+ // ─── exportDist ───────────────────────────────────────────────────────────────
89
+
90
+ export interface ExportDistOptions {
91
+ /** Patterns glob supplémentaires à ignorer (en plus du .gitignore et de dist/). */
92
+ ignore?: string[];
93
+ }
94
+
95
+ export interface ExportDistStats {
96
+ copied: number;
97
+ skipped: number;
98
+ }
99
+
100
+ /**
101
+ * Copie les fichiers de `src` vers `dist` en respectant le .gitignore,
102
+ * en excluant les fichiers SCSS, JS non-minifiés et les fichiers/dossiers
103
+ * préfixés par `_`.
104
+ * Injecte automatiquement un banner dans les fichiers .js, .css et .html,
105
+ * et remplace les tokens ###YEAR###, ###TIMESTAMP### et ###TODAY###.
106
+ *
107
+ * @param src Dossier source.
108
+ * @param dist Dossier de destination (vidé avant la copie).
109
+ * @param banner Chemin vers un fichier texte de banner personnalisé (optionnel).
110
+ * @param options Options supplémentaires.
111
+ */
112
+ export function exportDist(
113
+ src: string,
114
+ dist: string,
115
+ banner?: string | null,
116
+ options?: ExportDistOptions
117
+ ): Promise<ExportDistStats>;
118
+
119
+ // ─── createWatchers ───────────────────────────────────────────────────────────
120
+
121
+ export type GlobPattern = string;
122
+
123
+ export type IgnoreMatcher =
124
+ | string
125
+ | RegExp
126
+ | ((relPosixPath: string) => boolean);
127
+
128
+ export type WatchEventType = "add" | "change" | "unlink" | (string & {});
129
+
130
+ export interface WatchEvent {
131
+ type: WatchEventType;
132
+ /** Chemin relatif au cwd, en format posix. */
133
+ file: string;
134
+ }
135
+
136
+ export interface WatchRuleContext {
137
+ rule: WatchRule;
138
+ }
139
+
140
+ export interface WatchRule {
141
+ /** Nom de la règle (utilisé dans les logs). */
142
+ name?: string;
143
+ /** Un ou plusieurs patterns glob à surveiller. */
144
+ patterns: GlobPattern | GlobPattern[];
145
+ /** Patterns/regex/fonctions à ignorer pour cette règle. */
146
+ ignored?: IgnoreMatcher[];
147
+ /** Délai de debounce en ms avant de déclencher le callback (défaut : 150). */
148
+ debounceMs?: number;
149
+ /** Appelé avec le batch d'événements déclencheurs. */
150
+ callback: (events: WatchEvent[], ctx: WatchRuleContext) => void | Promise<void>;
151
+ }
152
+
153
+ export interface AwaitWriteFinishOptions {
154
+ stabilityThreshold?: number;
155
+ pollInterval?: number;
156
+ }
157
+
158
+ export interface CreateWatchersOptions {
159
+ /** Répertoire de travail (défaut : process.cwd()). */
160
+ cwd?: string;
161
+ /** Patterns ignorés globalement, appliqués à toutes les règles (défaut : node_modules, .git, dist). */
162
+ globalIgnored?: string[];
163
+ /** Ignorer les événements au démarrage du watcher (défaut : true). */
164
+ ignoreInitial?: boolean;
165
+ awaitWriteFinish?: boolean | AwaitWriteFinishOptions;
166
+ /** Activer le polling (utile sous WSL, OneDrive, montages réseau). */
167
+ usePolling?: boolean;
168
+ interval?: number;
169
+ binaryInterval?: number;
170
+ /** Activer les logs de debug (défaut : true). */
171
+ debug?: boolean;
172
+ [key: string]: unknown;
173
+ }
174
+
175
+ export interface WatchersController {
176
+ /** Arrête proprement tous les watchers et vide les queues. */
177
+ close: () => Promise<void>;
178
+ }
179
+
180
+ /**
181
+ * Crée un ou plusieurs watchers chokidar avec filtrage par patterns glob,
182
+ * debounce, et exécution sérialisée des callbacks.
183
+ *
184
+ * @param rules Liste des règles de surveillance.
185
+ * @param options Options globales des watchers.
186
+ */
187
+ export function createWatchers(
188
+ rules: WatchRule[],
189
+ options?: CreateWatchersOptions
190
+ ): WatchersController;
package/index.js CHANGED
@@ -1,8 +1,6 @@
1
- module.exports = {
2
- ...require("./src/buildjs.js"),
3
- ...require("./src/buildcss.js"),
4
- ...require("./src/buildphp.js"),
5
- ...require("./src/buildconf.js"),
6
- ...require("./src/export.js"),
7
- ...require("./src/watchers.js"),
8
- };
1
+ export { buildJS } from "./src/buildjs.js";
2
+ export { buildCSS } from "./src/buildcss.js";
3
+ export { buildPHP, buildSitemap } from "./src/buildphp.js";
4
+ export { buildConf } from "./src/buildconf.js";
5
+ export { exportDist } from "./src/export.js";
6
+ export { createWatchers } from "./src/watchers.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chokibasic",
3
- "version": "1.2.3",
3
+ "version": "2.0.1",
4
4
  "description": "Basic chokidar watcher + pxpros + esbuild + sass + csso helpers",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "author": "Maxime Larrivée-Roy",
27
27
  "license": "MIT",
28
- "type": "commonjs",
28
+ "type": "module",
29
29
  "bugs": {
30
30
  "url": "https://github.com/ZmotriN/chokibasic/issues"
31
31
  },
@@ -35,9 +35,13 @@
35
35
  "csso": "^5.0.5",
36
36
  "esbuild": "^0.28.0",
37
37
  "ignore": "^7.0.5",
38
- "js-yaml": "^4.1.1",
38
+ "js-yaml": "^4.2.0",
39
39
  "picomatch": "^4.0.4",
40
- "pxpros": "^1.1.3",
40
+ "pxpros": "^2.0.1",
41
41
  "sass": "^1.100.0"
42
+ },
43
+ "allowScripts": {
44
+ "@parcel/watcher@2.5.6": true,
45
+ "esbuild@0.28.0": true
42
46
  }
43
47
  }
package/readme.md CHANGED
@@ -235,6 +235,12 @@ await exportDist("src", "dist", "src/banner.txt");
235
235
 
236
236
  ## Changelog
237
237
 
238
+ ## Version 2.0.1
239
+ * PXPros v2.0.1 with YAML for PHP
240
+
241
+ ## Version 2.0.0
242
+ * PXPros v2.0.0 with PHP-WASM included
243
+
238
244
  ### Version 1.1.8
239
245
  * Update dependancy: pxpros 1.1.3
240
246
 
package/src/buildconf.js CHANGED
@@ -1,7 +1,7 @@
1
- const fs = require('fs/promises');
2
- const path = require("path");
3
- const yaml = require("js-yaml");
4
- const pm = require("picomatch");
1
+ import fs from 'fs/promises';
2
+ import path from "path";
3
+ import yaml from "js-yaml";
4
+ import pm from "picomatch";
5
5
 
6
6
  const ROOT = process.cwd();
7
7
 
@@ -71,4 +71,4 @@ async function buildConf(src, dst, matchers = {}) {
71
71
  }
72
72
  }
73
73
 
74
- module.exports = { buildConf };
74
+ export { buildConf };
package/src/buildcss.js CHANGED
@@ -1,7 +1,7 @@
1
- const sass = require("sass");
2
- const csso = require("csso");
3
- const path = require("path");
4
- const fs = require("node:fs");
1
+ import * as sass from 'sass'
2
+ import { minify } from 'csso';
3
+ import path from "path";
4
+ import fs from "node:fs";
5
5
 
6
6
  const buildCSS = async (inputScss, outCssMin, options = {}) => {
7
7
  // let compiled;
@@ -16,7 +16,7 @@ const buildCSS = async (inputScss, outCssMin, options = {}) => {
16
16
  if(options?.style == "expanded"){
17
17
  fs.writeFileSync(outCssMin, compiled.css);
18
18
  } else {
19
- const minified = csso.minify(compiled.css, { restructure: false });
19
+ const minified = minify(compiled.css, { restructure: false });
20
20
  fs.writeFileSync(outCssMin, minified.css);
21
21
  }
22
22
  console.log(`✅ CSS generated: ${outCssMin}`);
@@ -26,4 +26,4 @@ const buildCSS = async (inputScss, outCssMin, options = {}) => {
26
26
  }
27
27
  }
28
28
 
29
- module.exports = { buildCSS };
29
+ export { buildCSS };
package/src/buildjs.js CHANGED
@@ -1,4 +1,5 @@
1
- const esbuild = require("esbuild");
1
+ // const esbuild = require("esbuild");
2
+ import esbuild from "esbuild";
2
3
 
3
4
 
4
5
  const buildJS = async (entry, outfile, options = {}) => {
@@ -33,4 +34,4 @@ const buildJS = async (entry, outfile, options = {}) => {
33
34
  }
34
35
  }
35
36
 
36
- module.exports = { buildJS };
37
+ export { buildJS };
package/src/buildphp.js CHANGED
@@ -1,8 +1,8 @@
1
- const pxpros = require("pxpros");
1
+ import { sitemap, render } from "pxpros";
2
2
 
3
3
 
4
4
  const buildPHP = async (file) => {
5
- const results = await pxpros.render(file);
5
+ const results = await render(file);
6
6
  if(results.success) {
7
7
  results.files.forEach(file => console.log(`✅ HTML generated: ${file}`));
8
8
  } else {
@@ -13,7 +13,7 @@ const buildPHP = async (file) => {
13
13
 
14
14
 
15
15
  const buildSitemap = async (file) => {
16
- const results = await pxpros.sitemap(file);
16
+ const results = await sitemap(file);
17
17
  if(results.success) {
18
18
  results.files.forEach(file => console.log(`✅ XML Sitemap generated: ${file}`));
19
19
  } else {
@@ -22,4 +22,4 @@ const buildSitemap = async (file) => {
22
22
  }
23
23
  }
24
24
 
25
- module.exports = { buildPHP, buildSitemap };
25
+ export { buildPHP, buildSitemap };
package/src/export.js CHANGED
@@ -1,10 +1,15 @@
1
- const fsprom = require('fs/promises');
2
- const ignore = require('ignore');
3
- const fs = require("node:fs");
4
- const path = require("path");
1
+ import fsprom from 'fs/promises';
2
+ import ignore from 'ignore';
3
+ import fs from "node:fs";
4
+ import path from "path";
5
+ import { fileURLToPath } from 'url';
5
6
 
7
+
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
9
  const ROOT = process.cwd();
7
10
 
11
+
12
+
8
13
  async function emptyDir(dir) {
9
14
  await fsprom.mkdir(dir, { recursive: true });
10
15
  const entries = await fsprom.readdir(dir, { withFileTypes: true });
@@ -172,4 +177,4 @@ const exportDist = async (src, dist, banner = null, options = {}) => {
172
177
  }
173
178
  };
174
179
 
175
- module.exports = { exportDist };
180
+ export { exportDist };
package/src/watchers.js CHANGED
@@ -1,5 +1,5 @@
1
- const path = require("path");
2
- const chokidar = require("chokidar");
1
+ import path from "path";
2
+ import chokidar from "chokidar";
3
3
 
4
4
  function toPosix(p) {
5
5
  return p.replace(/\\/g, "/");
@@ -200,4 +200,4 @@ function createWatchers(rules, options = {}) {
200
200
  };
201
201
  }
202
202
 
203
- module.exports = { createWatchers };
203
+ export { createWatchers };