@learnpack/learnpack 5.0.340 → 5.0.341

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/lib/utils/api.js CHANGED
@@ -460,8 +460,17 @@ const createRigoPackage = async (token, slug, config) => {
460
460
  }
461
461
  };
462
462
  let technologiesCache = [];
463
+ /** Strip .env comments (e.g. "token # comment") so the token is sent without spaces. */
464
+ function sanitizeToken(token) {
465
+ if (!token)
466
+ return "";
467
+ const trimmed = token.trim();
468
+ const beforeComment = trimmed.split(/\s+#/)[0].trim();
469
+ return beforeComment;
470
+ }
463
471
  const fetchTechnologies = async () => {
464
- const BREATHECODE_PERMANENT_TOKEN = process.env.BREATHECODE_PERMANENT_TOKEN;
472
+ const rawToken = process.env.BREATHECODE_PERMANENT_TOKEN;
473
+ const BREATHECODE_PERMANENT_TOKEN = sanitizeToken(rawToken);
465
474
  const LANGS = ["en", "es"];
466
475
  if (!BREATHECODE_PERMANENT_TOKEN) {
467
476
  throw new Error("BREATHECODE_PERMANENT_TOKEN is not defined in environment variables");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@learnpack/learnpack",
3
3
  "description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
4
- "version": "5.0.340",
4
+ "version": "5.0.341",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -1184,7 +1184,8 @@ class ServeCommand extends SessionCommand {
1184
1184
  process.env.GCP_BUCKET_NAME || "learnpack-packages"
1185
1185
  )
1186
1186
 
1187
- const host = process.env.HOST
1187
+ const rawHost = process.env.HOST || ""
1188
+ const host = rawHost.trim().split(/\s+#/)[0].trim()
1188
1189
 
1189
1190
  if (!host) {
1190
1191
  console.log(
@@ -1196,15 +1197,31 @@ class ServeCommand extends SessionCommand {
1196
1197
  }
1197
1198
 
1198
1199
  // Initialize Redis (official client)
1199
- const redisUrl = process.env.REDIS_URL || "redis://localhost:6379"
1200
+ let redisUrl = (process.env.REDIS_URL || "redis://localhost:6379").trim()
1201
+ // Strip surrounding quotes if present (e.g. from .env)
1202
+ if (
1203
+ (redisUrl.startsWith('"') && redisUrl.endsWith('"')) ||
1204
+ (redisUrl.startsWith("'") && redisUrl.endsWith("'"))
1205
+ ) {
1206
+ redisUrl = redisUrl.slice(1, -1)
1207
+ }
1208
+
1209
+ const isPlaceholderRedisUrl =
1210
+ redisUrl.includes("your_production_password") ||
1211
+ redisUrl.includes("your-redis-instance.cloud")
1200
1212
 
1201
1213
  if (
1202
1214
  process.env.NODE_ENV === "production" &&
1203
- redisUrl === "redis://localhost:6379"
1215
+ (redisUrl === "redis://localhost:6379" || isPlaceholderRedisUrl)
1204
1216
  ) {
1205
1217
  console.error("❌ REDIS_URL not configured for production environment!")
1206
1218
  console.warn("⚠️ History features will be unavailable")
1207
1219
  this.redis = null
1220
+ } else if (isPlaceholderRedisUrl) {
1221
+ console.warn(
1222
+ "⚠️ REDIS_URL looks like a placeholder; skipping Redis. History features (undo/redo) will be unavailable"
1223
+ )
1224
+ this.redis = null
1208
1225
  } else {
1209
1226
  try {
1210
1227
  const useTLS = redisUrl.startsWith("rediss://")
@@ -1262,7 +1279,9 @@ class ServeCommand extends SessionCommand {
1262
1279
  const server = http.createServer(app)
1263
1280
  initSocketIO(server)
1264
1281
 
1265
- const PORT = process.env.PORT || 3000
1282
+ const rawPort = process.env.PORT || "3000"
1283
+ const PORT =
1284
+ parseInt(String(rawPort).trim().split(/\s+#/)[0].trim(), 10) || 3000
1266
1285
 
1267
1286
  const distPath = path.resolve(__dirname, "../creatorDist")
1268
1287