@lystech/core 1.0.4 → 3.0.5
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 +1 -1
- package/bin/README.md +126 -126
- package/bin/attach.cjs +277 -277
- package/bin/check-pwa.cjs +276 -276
- package/bin/setup-github-action.cjs +209 -209
- package/dist/lystech-core-provider.es.js +1 -1
- package/dist/lystech-core-provider.umd.js +1 -1
- package/package.json +73 -73
|
@@ -1,209 +1,209 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
|
|
6
|
-
const DEFAULT_WORKFLOW_FILE = "lystech-auto-update-and-deploy.yml";
|
|
7
|
-
const DEFAULT_PACKAGE_NAME = "lystechcorenpmpackage";
|
|
8
|
-
const DEFAULT_DEPLOY_SCRIPT = "deploy";
|
|
9
|
-
|
|
10
|
-
function printHelp() {
|
|
11
|
-
console.log("Usage: lystech-auto-update-init [options]");
|
|
12
|
-
console.log("");
|
|
13
|
-
console.log("Options:");
|
|
14
|
-
console.log(
|
|
15
|
-
" --force Ecrase le workflow s'il existe deja",
|
|
16
|
-
);
|
|
17
|
-
console.log(
|
|
18
|
-
" --dry-run Affiche le YAML sans ecrire de fichier",
|
|
19
|
-
);
|
|
20
|
-
console.log(" --package=<name> Nom du package a surveiller");
|
|
21
|
-
console.log(
|
|
22
|
-
" --deploy-script=<script> Script npm de deploiement (defaut: deploy)",
|
|
23
|
-
);
|
|
24
|
-
console.log(" --workflow-file=<file> Nom du fichier workflow cible");
|
|
25
|
-
console.log(" --help Affiche cette aide");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function hasArg(name) {
|
|
29
|
-
return process.argv.includes(name);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function readArg(name, fallback) {
|
|
33
|
-
const arg = process.argv.find((item) => item.startsWith(`${name}=`));
|
|
34
|
-
if (!arg) return fallback;
|
|
35
|
-
const value = arg.slice(name.length + 1).trim();
|
|
36
|
-
return value || fallback;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function ensureRepoRoot(cwd) {
|
|
40
|
-
const packageJsonPath = path.join(cwd, "package.json");
|
|
41
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
"package.json introuvable. Lance la commande depuis la racine du repo consommateur.",
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const packageJsonRaw = fs.readFileSync(packageJsonPath, "utf8");
|
|
48
|
-
return JSON.parse(packageJsonRaw);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function buildWorkflowYml(packageName, deployScript) {
|
|
52
|
-
return `# ⚠️ WORKFLOW OPTIONNEL - Auto-Update Manual Fallback
|
|
53
|
-
#
|
|
54
|
-
# Ce workflow n'est PAS nécessaire si le package LystechCore est correctement configuré.
|
|
55
|
-
# Le package gère automatiquement les mises à jour via son propre workflow centralisé.
|
|
56
|
-
#
|
|
57
|
-
# Gardez ce workflow uniquement si:
|
|
58
|
-
# - Vous voulez un fallback manuel (workflow_dispatch)
|
|
59
|
-
# - Vous voulez une vérification quotidienne supplémentaire (schedule)
|
|
60
|
-
# - Le workflow centralisé du package n'a pas accès à ce repo
|
|
61
|
-
#
|
|
62
|
-
# Sinon, vous pouvez supprimer ce fichier en toute sécurité.
|
|
63
|
-
|
|
64
|
-
name: Lystech Auto Update (Fallback)
|
|
65
|
-
|
|
66
|
-
on:
|
|
67
|
-
# Déclenché manuellement si besoin
|
|
68
|
-
workflow_dispatch:
|
|
69
|
-
# Vérification quotidienne (backup si le workflow centralisé échoue)
|
|
70
|
-
schedule:
|
|
71
|
-
- cron: '0 9 * * *'
|
|
72
|
-
|
|
73
|
-
permissions:
|
|
74
|
-
contents: write
|
|
75
|
-
|
|
76
|
-
jobs:
|
|
77
|
-
update-and-deploy:
|
|
78
|
-
runs-on: ubuntu-latest
|
|
79
|
-
|
|
80
|
-
steps:
|
|
81
|
-
- name: Checkout
|
|
82
|
-
uses: actions/checkout@v4
|
|
83
|
-
|
|
84
|
-
- name: Setup Node
|
|
85
|
-
uses: actions/setup-node@v4
|
|
86
|
-
with:
|
|
87
|
-
node-version: 20
|
|
88
|
-
cache: npm
|
|
89
|
-
|
|
90
|
-
- name: Install dependencies
|
|
91
|
-
run: npm ci
|
|
92
|
-
|
|
93
|
-
- name: Check latest version
|
|
94
|
-
id: target
|
|
95
|
-
shell: bash
|
|
96
|
-
run: |
|
|
97
|
-
TARGET_VERSION=$(npm view ${packageName} version)
|
|
98
|
-
echo "version=$TARGET_VERSION" >> "$GITHUB_OUTPUT"
|
|
99
|
-
echo "Target version: $TARGET_VERSION"
|
|
100
|
-
|
|
101
|
-
- name: Read installed version
|
|
102
|
-
id: current
|
|
103
|
-
shell: bash
|
|
104
|
-
run: |
|
|
105
|
-
INSTALLED_VERSION=$(node -e "const pkg=require('./package.json'); const v=(pkg.dependencies&&pkg.dependencies['${packageName}'])||(pkg.devDependencies&&pkg.devDependencies['${packageName}'])||(pkg.peerDependencies&&pkg.peerDependencies['${packageName}'])||''; console.log(v.replace(/^[^0-9]*/,''));")
|
|
106
|
-
echo "version=$INSTALLED_VERSION" >> "$GITHUB_OUTPUT"
|
|
107
|
-
echo "Installed version: $INSTALLED_VERSION"
|
|
108
|
-
|
|
109
|
-
- name: Detect if update is required
|
|
110
|
-
id: changes
|
|
111
|
-
shell: bash
|
|
112
|
-
run: |
|
|
113
|
-
if [ "\${{ steps.current.outputs.version }}" = "\${{ steps.target.outputs.version }}" ]; then
|
|
114
|
-
echo "updated=false" >> "$GITHUB_OUTPUT"
|
|
115
|
-
echo "✅ Déjà à jour"
|
|
116
|
-
else
|
|
117
|
-
echo "updated=true" >> "$GITHUB_OUTPUT"
|
|
118
|
-
echo "🔄 Mise à jour disponible"
|
|
119
|
-
fi
|
|
120
|
-
|
|
121
|
-
- name: Update package
|
|
122
|
-
if: steps.changes.outputs.updated == 'true'
|
|
123
|
-
run: npm install ${packageName}@\${{ steps.target.outputs.version }}
|
|
124
|
-
|
|
125
|
-
- name: Build
|
|
126
|
-
if: steps.changes.outputs.updated == 'true'
|
|
127
|
-
run: npm run build
|
|
128
|
-
|
|
129
|
-
- name: Deploy
|
|
130
|
-
if: steps.changes.outputs.updated == 'true'
|
|
131
|
-
run: npm run ${deployScript}
|
|
132
|
-
|
|
133
|
-
- name: Commit and push dependency update
|
|
134
|
-
if: steps.changes.outputs.updated == 'true'
|
|
135
|
-
shell: bash
|
|
136
|
-
run: |
|
|
137
|
-
git config user.name "github-actions[bot]"
|
|
138
|
-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
139
|
-
git add package.json package-lock.json
|
|
140
|
-
git commit -m "chore(deps): update ${packageName} to \${{ steps.target.outputs.version }}"
|
|
141
|
-
git push
|
|
142
|
-
`;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function main() {
|
|
146
|
-
if (hasArg("--help") || hasArg("-h")) {
|
|
147
|
-
printHelp();
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const cwd = process.cwd();
|
|
152
|
-
const dryRun = hasArg("--dry-run");
|
|
153
|
-
const force = hasArg("--force");
|
|
154
|
-
|
|
155
|
-
const packageName = readArg("--package", DEFAULT_PACKAGE_NAME);
|
|
156
|
-
const deployScript = readArg("--deploy-script", DEFAULT_DEPLOY_SCRIPT);
|
|
157
|
-
const workflowFile = readArg("--workflow-file", DEFAULT_WORKFLOW_FILE);
|
|
158
|
-
|
|
159
|
-
const rootPackageJson = ensureRepoRoot(cwd);
|
|
160
|
-
const scripts = rootPackageJson.scripts || {};
|
|
161
|
-
|
|
162
|
-
if (!scripts[deployScript]) {
|
|
163
|
-
console.warn(
|
|
164
|
-
`Attention: script npm '${deployScript}' introuvable dans package.json.`,
|
|
165
|
-
);
|
|
166
|
-
console.warn(
|
|
167
|
-
"Le workflow sera quand meme genere, mais pense a ajuster --deploy-script.",
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const workflowDir = path.join(cwd, ".github", "workflows");
|
|
172
|
-
const workflowPath = path.join(workflowDir, workflowFile);
|
|
173
|
-
const workflowContent = buildWorkflowYml(packageName, deployScript);
|
|
174
|
-
|
|
175
|
-
if (fs.existsSync(workflowPath) && !force) {
|
|
176
|
-
console.error(`Le fichier existe deja: ${workflowPath}`);
|
|
177
|
-
console.error(
|
|
178
|
-
"Utilise --force pour ecraser, ou --workflow-file pour un nouveau nom.",
|
|
179
|
-
);
|
|
180
|
-
process.exit(1);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (dryRun) {
|
|
184
|
-
console.log("[DRY RUN] Workflow cible:", workflowPath);
|
|
185
|
-
console.log("\n------ BEGIN WORKFLOW ------\n");
|
|
186
|
-
console.log(workflowContent);
|
|
187
|
-
console.log("------ END WORKFLOW ------\n");
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
fs.mkdirSync(workflowDir, { recursive: true });
|
|
192
|
-
fs.writeFileSync(workflowPath, workflowContent, "utf8");
|
|
193
|
-
|
|
194
|
-
console.log("Workflow GitHub Action genere avec succes:");
|
|
195
|
-
console.log(workflowPath);
|
|
196
|
-
console.log("\nEtapes suivantes conseillees:");
|
|
197
|
-
console.log("1) Commit/push le workflow dans le repo consommateur.");
|
|
198
|
-
console.log("2) Configure les secrets Firebase requis pour npm run deploy.");
|
|
199
|
-
console.log(
|
|
200
|
-
"3) Le workflow detecte automatiquement les nouvelles versions npm via schedule (et repository_dispatch si configure).",
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
try {
|
|
205
|
-
main();
|
|
206
|
-
} catch (error) {
|
|
207
|
-
console.error("Erreur:", error.message || error);
|
|
208
|
-
process.exit(1);
|
|
209
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const DEFAULT_WORKFLOW_FILE = "lystech-auto-update-and-deploy.yml";
|
|
7
|
+
const DEFAULT_PACKAGE_NAME = "lystechcorenpmpackage";
|
|
8
|
+
const DEFAULT_DEPLOY_SCRIPT = "deploy";
|
|
9
|
+
|
|
10
|
+
function printHelp() {
|
|
11
|
+
console.log("Usage: lystech-auto-update-init [options]");
|
|
12
|
+
console.log("");
|
|
13
|
+
console.log("Options:");
|
|
14
|
+
console.log(
|
|
15
|
+
" --force Ecrase le workflow s'il existe deja",
|
|
16
|
+
);
|
|
17
|
+
console.log(
|
|
18
|
+
" --dry-run Affiche le YAML sans ecrire de fichier",
|
|
19
|
+
);
|
|
20
|
+
console.log(" --package=<name> Nom du package a surveiller");
|
|
21
|
+
console.log(
|
|
22
|
+
" --deploy-script=<script> Script npm de deploiement (defaut: deploy)",
|
|
23
|
+
);
|
|
24
|
+
console.log(" --workflow-file=<file> Nom du fichier workflow cible");
|
|
25
|
+
console.log(" --help Affiche cette aide");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function hasArg(name) {
|
|
29
|
+
return process.argv.includes(name);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function readArg(name, fallback) {
|
|
33
|
+
const arg = process.argv.find((item) => item.startsWith(`${name}=`));
|
|
34
|
+
if (!arg) return fallback;
|
|
35
|
+
const value = arg.slice(name.length + 1).trim();
|
|
36
|
+
return value || fallback;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ensureRepoRoot(cwd) {
|
|
40
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
41
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"package.json introuvable. Lance la commande depuis la racine du repo consommateur.",
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const packageJsonRaw = fs.readFileSync(packageJsonPath, "utf8");
|
|
48
|
+
return JSON.parse(packageJsonRaw);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function buildWorkflowYml(packageName, deployScript) {
|
|
52
|
+
return `# ⚠️ WORKFLOW OPTIONNEL - Auto-Update Manual Fallback
|
|
53
|
+
#
|
|
54
|
+
# Ce workflow n'est PAS nécessaire si le package LystechCore est correctement configuré.
|
|
55
|
+
# Le package gère automatiquement les mises à jour via son propre workflow centralisé.
|
|
56
|
+
#
|
|
57
|
+
# Gardez ce workflow uniquement si:
|
|
58
|
+
# - Vous voulez un fallback manuel (workflow_dispatch)
|
|
59
|
+
# - Vous voulez une vérification quotidienne supplémentaire (schedule)
|
|
60
|
+
# - Le workflow centralisé du package n'a pas accès à ce repo
|
|
61
|
+
#
|
|
62
|
+
# Sinon, vous pouvez supprimer ce fichier en toute sécurité.
|
|
63
|
+
|
|
64
|
+
name: Lystech Auto Update (Fallback)
|
|
65
|
+
|
|
66
|
+
on:
|
|
67
|
+
# Déclenché manuellement si besoin
|
|
68
|
+
workflow_dispatch:
|
|
69
|
+
# Vérification quotidienne (backup si le workflow centralisé échoue)
|
|
70
|
+
schedule:
|
|
71
|
+
- cron: '0 9 * * *'
|
|
72
|
+
|
|
73
|
+
permissions:
|
|
74
|
+
contents: write
|
|
75
|
+
|
|
76
|
+
jobs:
|
|
77
|
+
update-and-deploy:
|
|
78
|
+
runs-on: ubuntu-latest
|
|
79
|
+
|
|
80
|
+
steps:
|
|
81
|
+
- name: Checkout
|
|
82
|
+
uses: actions/checkout@v4
|
|
83
|
+
|
|
84
|
+
- name: Setup Node
|
|
85
|
+
uses: actions/setup-node@v4
|
|
86
|
+
with:
|
|
87
|
+
node-version: 20
|
|
88
|
+
cache: npm
|
|
89
|
+
|
|
90
|
+
- name: Install dependencies
|
|
91
|
+
run: npm ci
|
|
92
|
+
|
|
93
|
+
- name: Check latest version
|
|
94
|
+
id: target
|
|
95
|
+
shell: bash
|
|
96
|
+
run: |
|
|
97
|
+
TARGET_VERSION=$(npm view ${packageName} version)
|
|
98
|
+
echo "version=$TARGET_VERSION" >> "$GITHUB_OUTPUT"
|
|
99
|
+
echo "Target version: $TARGET_VERSION"
|
|
100
|
+
|
|
101
|
+
- name: Read installed version
|
|
102
|
+
id: current
|
|
103
|
+
shell: bash
|
|
104
|
+
run: |
|
|
105
|
+
INSTALLED_VERSION=$(node -e "const pkg=require('./package.json'); const v=(pkg.dependencies&&pkg.dependencies['${packageName}'])||(pkg.devDependencies&&pkg.devDependencies['${packageName}'])||(pkg.peerDependencies&&pkg.peerDependencies['${packageName}'])||''; console.log(v.replace(/^[^0-9]*/,''));")
|
|
106
|
+
echo "version=$INSTALLED_VERSION" >> "$GITHUB_OUTPUT"
|
|
107
|
+
echo "Installed version: $INSTALLED_VERSION"
|
|
108
|
+
|
|
109
|
+
- name: Detect if update is required
|
|
110
|
+
id: changes
|
|
111
|
+
shell: bash
|
|
112
|
+
run: |
|
|
113
|
+
if [ "\${{ steps.current.outputs.version }}" = "\${{ steps.target.outputs.version }}" ]; then
|
|
114
|
+
echo "updated=false" >> "$GITHUB_OUTPUT"
|
|
115
|
+
echo "✅ Déjà à jour"
|
|
116
|
+
else
|
|
117
|
+
echo "updated=true" >> "$GITHUB_OUTPUT"
|
|
118
|
+
echo "🔄 Mise à jour disponible"
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
- name: Update package
|
|
122
|
+
if: steps.changes.outputs.updated == 'true'
|
|
123
|
+
run: npm install ${packageName}@\${{ steps.target.outputs.version }}
|
|
124
|
+
|
|
125
|
+
- name: Build
|
|
126
|
+
if: steps.changes.outputs.updated == 'true'
|
|
127
|
+
run: npm run build
|
|
128
|
+
|
|
129
|
+
- name: Deploy
|
|
130
|
+
if: steps.changes.outputs.updated == 'true'
|
|
131
|
+
run: npm run ${deployScript}
|
|
132
|
+
|
|
133
|
+
- name: Commit and push dependency update
|
|
134
|
+
if: steps.changes.outputs.updated == 'true'
|
|
135
|
+
shell: bash
|
|
136
|
+
run: |
|
|
137
|
+
git config user.name "github-actions[bot]"
|
|
138
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
139
|
+
git add package.json package-lock.json
|
|
140
|
+
git commit -m "chore(deps): update ${packageName} to \${{ steps.target.outputs.version }}"
|
|
141
|
+
git push
|
|
142
|
+
`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function main() {
|
|
146
|
+
if (hasArg("--help") || hasArg("-h")) {
|
|
147
|
+
printHelp();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const cwd = process.cwd();
|
|
152
|
+
const dryRun = hasArg("--dry-run");
|
|
153
|
+
const force = hasArg("--force");
|
|
154
|
+
|
|
155
|
+
const packageName = readArg("--package", DEFAULT_PACKAGE_NAME);
|
|
156
|
+
const deployScript = readArg("--deploy-script", DEFAULT_DEPLOY_SCRIPT);
|
|
157
|
+
const workflowFile = readArg("--workflow-file", DEFAULT_WORKFLOW_FILE);
|
|
158
|
+
|
|
159
|
+
const rootPackageJson = ensureRepoRoot(cwd);
|
|
160
|
+
const scripts = rootPackageJson.scripts || {};
|
|
161
|
+
|
|
162
|
+
if (!scripts[deployScript]) {
|
|
163
|
+
console.warn(
|
|
164
|
+
`Attention: script npm '${deployScript}' introuvable dans package.json.`,
|
|
165
|
+
);
|
|
166
|
+
console.warn(
|
|
167
|
+
"Le workflow sera quand meme genere, mais pense a ajuster --deploy-script.",
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const workflowDir = path.join(cwd, ".github", "workflows");
|
|
172
|
+
const workflowPath = path.join(workflowDir, workflowFile);
|
|
173
|
+
const workflowContent = buildWorkflowYml(packageName, deployScript);
|
|
174
|
+
|
|
175
|
+
if (fs.existsSync(workflowPath) && !force) {
|
|
176
|
+
console.error(`Le fichier existe deja: ${workflowPath}`);
|
|
177
|
+
console.error(
|
|
178
|
+
"Utilise --force pour ecraser, ou --workflow-file pour un nouveau nom.",
|
|
179
|
+
);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (dryRun) {
|
|
184
|
+
console.log("[DRY RUN] Workflow cible:", workflowPath);
|
|
185
|
+
console.log("\n------ BEGIN WORKFLOW ------\n");
|
|
186
|
+
console.log(workflowContent);
|
|
187
|
+
console.log("------ END WORKFLOW ------\n");
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
fs.mkdirSync(workflowDir, { recursive: true });
|
|
192
|
+
fs.writeFileSync(workflowPath, workflowContent, "utf8");
|
|
193
|
+
|
|
194
|
+
console.log("Workflow GitHub Action genere avec succes:");
|
|
195
|
+
console.log(workflowPath);
|
|
196
|
+
console.log("\nEtapes suivantes conseillees:");
|
|
197
|
+
console.log("1) Commit/push le workflow dans le repo consommateur.");
|
|
198
|
+
console.log("2) Configure les secrets Firebase requis pour npm run deploy.");
|
|
199
|
+
console.log(
|
|
200
|
+
"3) Le workflow detecte automatiquement les nouvelles versions npm via schedule (et repository_dispatch si configure).",
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
main();
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.error("Erreur:", error.message || error);
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
@@ -41015,7 +41015,7 @@ function H9({ enableInstallAppButton: e, enablePushNotificationButton: t }) {
|
|
|
41015
41015
|
)
|
|
41016
41016
|
] });
|
|
41017
41017
|
}
|
|
41018
|
-
const V9 = "lystechcorenpmpackage", Y9 = "lystechcorenpmpackage:last-version", W9 = "
|
|
41018
|
+
const V9 = "lystechcorenpmpackage", Y9 = "lystechcorenpmpackage:last-version", W9 = "3.0.5";
|
|
41019
41019
|
function U9(e = {}) {
|
|
41020
41020
|
const {
|
|
41021
41021
|
packageName: t = V9,
|