@romaintaillandier1978/dotenv-never-lies 1.3.0 → 1.8.0

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.
Files changed (467) hide show
  1. package/README.md +84 -101
  2. package/dist/annotate/annotate-collector.d.ts +2 -0
  3. package/dist/annotate/annotate-collector.d.ts.map +1 -0
  4. package/dist/annotate/annotate-collector.js +48 -0
  5. package/dist/annotate/annotate-engine.d.ts +8 -0
  6. package/dist/annotate/annotate-engine.d.ts.map +1 -0
  7. package/dist/annotate/annotate-engine.js +52 -0
  8. package/dist/annotate/annotate-remove-engine.d.ts +2 -0
  9. package/dist/annotate/annotate-remove-engine.d.ts.map +1 -0
  10. package/dist/annotate/annotate-remove-engine.js +1 -0
  11. package/dist/annotate/helper.d.ts +26 -0
  12. package/dist/annotate/helper.d.ts.map +1 -0
  13. package/dist/annotate/helper.js +76 -0
  14. package/dist/annotate/report.type.d.ts +43 -0
  15. package/dist/annotate/report.type.d.ts.map +1 -0
  16. package/dist/annotate/report.type.js +7 -0
  17. package/dist/annotate/rules/add.d.ts +3 -0
  18. package/dist/annotate/rules/add.d.ts.map +1 -0
  19. package/dist/annotate/rules/add.js +67 -0
  20. package/dist/annotate/rules/annotate.d.ts +3 -0
  21. package/dist/annotate/rules/annotate.d.ts.map +1 -0
  22. package/dist/annotate/rules/annotate.js +30 -0
  23. package/dist/annotate/rules/check.d.ts +3 -0
  24. package/dist/annotate/rules/check.d.ts.map +1 -0
  25. package/dist/annotate/rules/check.js +56 -0
  26. package/dist/annotate/rules/fallback.d.ts +3 -0
  27. package/dist/annotate/rules/fallback.d.ts.map +1 -0
  28. package/dist/annotate/rules/fallback.js +36 -0
  29. package/dist/annotate/rules/ignore.d.ts +3 -0
  30. package/dist/annotate/rules/ignore.d.ts.map +1 -0
  31. package/dist/annotate/rules/ignore.js +40 -0
  32. package/dist/annotate/rules/process-env-var.d.ts +3 -0
  33. package/dist/annotate/rules/process-env-var.d.ts.map +1 -0
  34. package/dist/annotate/rules/process-env-var.js +36 -0
  35. package/dist/annotate/rules/recommandation.d.ts +3 -0
  36. package/dist/annotate/rules/recommandation.d.ts.map +1 -0
  37. package/dist/annotate/rules/recommandation.js +31 -0
  38. package/dist/annotate/rules/remove-annotation.d.ts +3 -0
  39. package/dist/annotate/rules/remove-annotation.d.ts.map +1 -0
  40. package/dist/annotate/rules/remove-annotation.js +48 -0
  41. package/dist/annotate/rules/remove.d.ts +3 -0
  42. package/dist/annotate/rules/remove.d.ts.map +1 -0
  43. package/dist/annotate/rules/remove.js +41 -0
  44. package/dist/annotate/rules/simple-annotation.d.ts +3 -0
  45. package/dist/annotate/rules/simple-annotation.d.ts.map +1 -0
  46. package/dist/annotate/rules/simple-annotation.js +53 -0
  47. package/dist/annotate/rules/warn-unknown-var.d.ts +3 -0
  48. package/dist/annotate/rules/warn-unknown-var.d.ts.map +1 -0
  49. package/dist/annotate/rules/warn-unknown-var.js +38 -0
  50. package/dist/annotate/types.d.ts +30 -0
  51. package/dist/annotate/types.d.ts.map +1 -0
  52. package/dist/annotate/types.js +1 -0
  53. package/dist/ast-tools/ast-helpers.d.ts +19 -0
  54. package/dist/ast-tools/ast-helpers.d.ts.map +1 -0
  55. package/dist/ast-tools/ast-helpers.js +94 -0
  56. package/dist/ast-tools/ast.types.d.ts +22 -0
  57. package/dist/ast-tools/ast.types.d.ts.map +1 -0
  58. package/dist/ast-tools/ast.types.js +1 -0
  59. package/dist/ast-tools/process-env-usage-collector.d.ts +10 -0
  60. package/dist/ast-tools/process-env-usage-collector.d.ts.map +1 -0
  61. package/dist/ast-tools/process-env-usage-collector.js +150 -0
  62. package/dist/cli/commands/annotate.d.ts +15 -0
  63. package/dist/cli/commands/annotate.d.ts.map +1 -0
  64. package/dist/cli/commands/annotate.js +88 -0
  65. package/dist/cli/commands/assert.d.ts +5 -1
  66. package/dist/cli/commands/assert.d.ts.map +1 -1
  67. package/dist/cli/commands/assert.js +6 -2
  68. package/dist/cli/commands/explain.d.ts.map +1 -1
  69. package/dist/cli/commands/explain.js +2 -0
  70. package/dist/cli/commands/export.d.ts +6 -30
  71. package/dist/cli/commands/export.d.ts.map +1 -1
  72. package/dist/cli/commands/export.js +20 -304
  73. package/dist/cli/commands/infer.d.ts +6 -3
  74. package/dist/cli/commands/infer.d.ts.map +1 -1
  75. package/dist/cli/commands/infer.js +215 -39
  76. package/dist/cli/commands/init.d.ts.map +1 -1
  77. package/dist/cli/commands/init.js +2 -0
  78. package/dist/cli/commands/process-check.d.ts +7 -0
  79. package/dist/cli/commands/process-check.d.ts.map +1 -0
  80. package/dist/cli/commands/process-check.js +6 -0
  81. package/dist/cli/commands/process-fix.d.ts +9 -0
  82. package/dist/cli/commands/process-fix.d.ts.map +1 -0
  83. package/dist/cli/commands/process-fix.js +58 -0
  84. package/dist/cli/commands/types.d.ts +14 -0
  85. package/dist/cli/commands/types.d.ts.map +1 -0
  86. package/dist/cli/commands/types.js +56 -0
  87. package/dist/cli/index.d.ts +2 -1
  88. package/dist/cli/index.d.ts.map +1 -1
  89. package/dist/cli/index.js +232 -220
  90. package/dist/cli/utils/infer-rule-engine.d.ts +5 -0
  91. package/dist/cli/utils/infer-rule-engine.d.ts.map +1 -0
  92. package/dist/cli/utils/infer-rule-engine.js +35 -0
  93. package/dist/cli/utils/load-schema.d.ts.map +1 -1
  94. package/dist/cli/utils/load-schema.js +1 -0
  95. package/dist/cli/utils/printer.d.ts.map +1 -1
  96. package/dist/cli/utils/printer.js +9 -9
  97. package/dist/cli/utils/report.d.ts +15 -0
  98. package/dist/cli/utils/report.d.ts.map +1 -0
  99. package/dist/cli/utils/report.js +173 -0
  100. package/dist/cli/utils/resolve-schema.d.ts.map +1 -1
  101. package/dist/cli/utils/resolve-schema.js +17 -16
  102. package/dist/cli/utils/valid-identifier.d.ts +3 -0
  103. package/dist/cli/utils/valid-identifier.d.ts.map +1 -0
  104. package/dist/cli/utils/valid-identifier.js +9 -0
  105. package/dist/core.d.ts +12 -6
  106. package/dist/core.d.ts.map +1 -1
  107. package/dist/core.js +29 -1
  108. package/dist/dnl-config.d.ts +10 -0
  109. package/dist/dnl-config.d.ts.map +1 -0
  110. package/dist/dnl-config.js +6 -0
  111. package/dist/errors.d.ts +5 -1
  112. package/dist/errors.d.ts.map +1 -1
  113. package/dist/errors.js +6 -0
  114. package/dist/export/export.types.d.ts +87 -0
  115. package/dist/export/export.types.d.ts.map +1 -0
  116. package/dist/export/export.types.js +8 -0
  117. package/dist/export/exporters/docker-args.exporter.d.ts +9 -0
  118. package/dist/export/exporters/docker-args.exporter.d.ts.map +1 -0
  119. package/dist/export/exporters/docker-args.exporter.js +33 -0
  120. package/dist/export/exporters/docker-env.exporter.d.ts +8 -0
  121. package/dist/export/exporters/docker-env.exporter.d.ts.map +1 -0
  122. package/dist/export/exporters/docker-env.exporter.js +19 -0
  123. package/dist/export/exporters/env.exporter.d.ts +8 -0
  124. package/dist/export/exporters/env.exporter.d.ts.map +1 -0
  125. package/dist/export/exporters/env.exporter.js +19 -0
  126. package/dist/export/exporters/github-env.exporter.d.ts +8 -0
  127. package/dist/export/exporters/github-env.exporter.d.ts.map +1 -0
  128. package/dist/export/exporters/github-env.exporter.js +15 -0
  129. package/dist/export/exporters/github-secret.exporter.d.ts +12 -0
  130. package/dist/export/exporters/github-secret.exporter.d.ts.map +1 -0
  131. package/dist/export/exporters/github-secret.exporter.js +38 -0
  132. package/dist/export/exporters/gitlab-env.exporter.d.ts +9 -0
  133. package/dist/export/exporters/gitlab-env.exporter.d.ts.map +1 -0
  134. package/dist/export/exporters/gitlab-env.exporter.js +25 -0
  135. package/dist/export/exporters/index.d.ts +12 -0
  136. package/dist/export/exporters/index.d.ts.map +1 -0
  137. package/dist/export/exporters/index.js +11 -0
  138. package/dist/export/exporters/js.exporter.d.ts +9 -0
  139. package/dist/export/exporters/js.exporter.d.ts.map +1 -0
  140. package/dist/export/exporters/js.exporter.js +24 -0
  141. package/dist/export/exporters/json.exporter.d.ts +12 -0
  142. package/dist/export/exporters/json.exporter.d.ts.map +1 -0
  143. package/dist/export/exporters/json.exporter.js +20 -0
  144. package/dist/export/exporters/k8s-configmap.exporter.d.ts +12 -0
  145. package/dist/export/exporters/k8s-configmap.exporter.d.ts.map +1 -0
  146. package/dist/export/exporters/k8s-configmap.exporter.js +37 -0
  147. package/dist/export/exporters/k8s-secret.exporter.d.ts +12 -0
  148. package/dist/export/exporters/k8s-secret.exporter.d.ts.map +1 -0
  149. package/dist/export/exporters/k8s-secret.exporter.js +35 -0
  150. package/dist/export/exporters/shared.d.ts +12 -0
  151. package/dist/export/exporters/shared.d.ts.map +1 -0
  152. package/dist/export/exporters/shared.js +35 -0
  153. package/dist/export/exporters/ts.exporter copy.d.ts +12 -0
  154. package/dist/export/exporters/ts.exporter copy.d.ts.map +1 -0
  155. package/dist/export/exporters/ts.exporter copy.js +25 -0
  156. package/dist/export/exporters/ts.exporter.d.ts +12 -0
  157. package/dist/export/exporters/ts.exporter.d.ts.map +1 -0
  158. package/dist/export/exporters/ts.exporter.js +25 -0
  159. package/dist/export/index.d.ts +3 -0
  160. package/dist/export/index.d.ts.map +1 -0
  161. package/dist/export/index.js +2 -0
  162. package/dist/export/registry.d.ts +17 -0
  163. package/dist/export/registry.d.ts.map +1 -0
  164. package/dist/export/registry.js +104 -0
  165. package/dist/export/shared.d.ts +31 -0
  166. package/dist/export/shared.d.ts.map +1 -0
  167. package/dist/export/shared.js +118 -0
  168. package/dist/index.d.ts +1 -0
  169. package/dist/index.d.ts.map +1 -1
  170. package/dist/index.js +6 -1
  171. package/dist/infer/__tests__/port-vs-version.test.js +1 -1
  172. package/dist/infer/__tests__/rules/basic.test.js +6 -6
  173. package/dist/infer/__tests__/rules/duration.test.js +2 -1
  174. package/dist/infer/__tests__/rules/json.test.js +1 -1
  175. package/dist/infer/__tests__/rules/key-value.test.d.ts +2 -0
  176. package/dist/infer/__tests__/rules/key-value.test.d.ts.map +1 -0
  177. package/dist/infer/__tests__/rules/key-value.test.js +56 -0
  178. package/dist/infer/__tests__/rules/list.test.js +12 -45
  179. package/dist/infer/__tests__/rules/url.test.js +2 -2
  180. package/dist/infer/__tests__/rules/version.test.js +1 -1
  181. package/dist/infer/cross-rules/secret-non-string.d.ts +3 -0
  182. package/dist/infer/cross-rules/secret-non-string.d.ts.map +1 -0
  183. package/dist/infer/cross-rules/secret-non-string.js +8 -0
  184. package/dist/infer/cross.d.ts +5 -0
  185. package/dist/infer/cross.d.ts.map +1 -0
  186. package/dist/infer/cross.js +16 -0
  187. package/dist/infer/cross.types.d.ts +30 -0
  188. package/dist/infer/cross.types.d.ts.map +1 -0
  189. package/dist/infer/cross.types.js +1 -0
  190. package/dist/infer/generated/basic.d.ts +7 -7
  191. package/dist/infer/generated/basic.d.ts.map +1 -1
  192. package/dist/infer/generated/basic.js +12 -6
  193. package/dist/infer/generated/boolean.d.ts +2 -2
  194. package/dist/infer/generated/boolean.d.ts.map +1 -1
  195. package/dist/infer/generated/boolean.js +3 -2
  196. package/dist/infer/generated/duration.d.ts +2 -2
  197. package/dist/infer/generated/duration.d.ts.map +1 -1
  198. package/dist/infer/generated/duration.js +1 -0
  199. package/dist/infer/generated/ip.d.ts +2 -2
  200. package/dist/infer/generated/ip.d.ts.map +1 -1
  201. package/dist/infer/generated/ip.js +1 -0
  202. package/dist/infer/generated/json.d.ts +3 -3
  203. package/dist/infer/generated/json.d.ts.map +1 -1
  204. package/dist/infer/generated/json.js +1 -0
  205. package/dist/infer/generated/key-value.d.ts +4 -0
  206. package/dist/infer/generated/key-value.d.ts.map +1 -0
  207. package/dist/infer/generated/key-value.js +11 -0
  208. package/dist/infer/generated/list.d.ts +5 -7
  209. package/dist/infer/generated/list.d.ts.map +1 -1
  210. package/dist/infer/generated/list.js +13 -21
  211. package/dist/infer/generated/port.d.ts +3 -3
  212. package/dist/infer/generated/port.d.ts.map +1 -1
  213. package/dist/infer/generated/port.js +1 -0
  214. package/dist/infer/generated/url.d.ts +13 -13
  215. package/dist/infer/generated/url.d.ts.map +1 -1
  216. package/dist/infer/generated/url.js +6 -0
  217. package/dist/infer/generated/version.d.ts +3 -3
  218. package/dist/infer/generated/version.d.ts.map +1 -1
  219. package/dist/infer/generated/version.js +1 -0
  220. package/dist/infer/helpers.d.ts +1 -3
  221. package/dist/infer/helpers.d.ts.map +1 -1
  222. package/dist/infer/helpers.js +5 -20
  223. package/dist/infer/heuristic.d.ts +4 -0
  224. package/dist/infer/heuristic.d.ts.map +1 -0
  225. package/dist/infer/heuristic.js +56 -0
  226. package/dist/infer/heuristic.types.d.ts +54 -0
  227. package/dist/infer/heuristic.types.d.ts.map +1 -0
  228. package/dist/infer/heuristic.types.js +1 -0
  229. package/dist/infer/heuristicRules.d.ts +6 -0
  230. package/dist/infer/heuristicRules.d.ts.map +1 -0
  231. package/dist/infer/heuristicRules.js +31 -0
  232. package/dist/infer/index.d.ts +2 -2
  233. package/dist/infer/index.d.ts.map +1 -1
  234. package/dist/infer/index.js +7 -11
  235. package/dist/infer/infer.types.d.ts +83 -0
  236. package/dist/infer/infer.types.d.ts.map +1 -0
  237. package/dist/infer/infer.types.js +17 -0
  238. package/dist/infer/official-preset-registry.d.ts +3 -0
  239. package/dist/infer/official-preset-registry.d.ts.map +1 -0
  240. package/dist/infer/official-preset-registry.js +67 -0
  241. package/dist/infer/presets/agenda.d.ts +3 -0
  242. package/dist/infer/presets/agenda.d.ts.map +1 -0
  243. package/dist/infer/presets/agenda.js +15 -0
  244. package/dist/infer/presets/amqplib.d.ts +3 -0
  245. package/dist/infer/presets/amqplib.d.ts.map +1 -0
  246. package/dist/infer/presets/amqplib.js +15 -0
  247. package/dist/infer/presets/aws-sdk.d.ts +3 -0
  248. package/dist/infer/presets/aws-sdk.d.ts.map +1 -0
  249. package/dist/infer/presets/aws-sdk.js +33 -0
  250. package/dist/infer/presets/aws-sdk_client-s3.d.ts +3 -0
  251. package/dist/infer/presets/aws-sdk_client-s3.d.ts.map +1 -0
  252. package/dist/infer/presets/aws-sdk_client-s3.js +15 -0
  253. package/dist/infer/presets/bcrypt.d.ts +3 -0
  254. package/dist/infer/presets/bcrypt.d.ts.map +1 -0
  255. package/dist/infer/presets/bcrypt.js +15 -0
  256. package/dist/infer/presets/bull.d.ts +3 -0
  257. package/dist/infer/presets/bull.d.ts.map +1 -0
  258. package/dist/infer/presets/bull.js +116 -0
  259. package/dist/infer/presets/cookie-parser.d.ts +3 -0
  260. package/dist/infer/presets/cookie-parser.d.ts.map +1 -0
  261. package/dist/infer/presets/cookie-parser.js +15 -0
  262. package/dist/infer/presets/cron.d.ts +3 -0
  263. package/dist/infer/presets/cron.d.ts.map +1 -0
  264. package/dist/infer/presets/cron.js +22 -0
  265. package/dist/infer/presets/dotenv.d.ts +3 -0
  266. package/dist/infer/presets/dotenv.d.ts.map +1 -0
  267. package/dist/infer/presets/dotenv.js +15 -0
  268. package/dist/infer/presets/express-session.d.ts +3 -0
  269. package/dist/infer/presets/express-session.d.ts.map +1 -0
  270. package/dist/infer/presets/express-session.js +40 -0
  271. package/dist/infer/presets/google-cloud_storage.d.ts +3 -0
  272. package/dist/infer/presets/google-cloud_storage.d.ts.map +1 -0
  273. package/dist/infer/presets/google-cloud_storage.js +15 -0
  274. package/dist/infer/presets/google-maps.d.ts +3 -0
  275. package/dist/infer/presets/google-maps.d.ts.map +1 -0
  276. package/dist/infer/presets/google-maps.js +15 -0
  277. package/dist/infer/presets/ioredis.d.ts +3 -0
  278. package/dist/infer/presets/ioredis.d.ts.map +1 -0
  279. package/dist/infer/presets/ioredis.js +15 -0
  280. package/dist/infer/presets/jsonwebtoken.d.ts +3 -0
  281. package/dist/infer/presets/jsonwebtoken.d.ts.map +1 -0
  282. package/dist/infer/presets/jsonwebtoken.js +40 -0
  283. package/dist/infer/presets/mongoose.d.ts +3 -0
  284. package/dist/infer/presets/mongoose.d.ts.map +1 -0
  285. package/dist/infer/presets/mongoose.js +15 -0
  286. package/dist/infer/presets/multer.d.ts +3 -0
  287. package/dist/infer/presets/multer.d.ts.map +1 -0
  288. package/dist/infer/presets/multer.js +15 -0
  289. package/dist/infer/presets/mysql2.d.ts +3 -0
  290. package/dist/infer/presets/mysql2.d.ts.map +1 -0
  291. package/dist/infer/presets/mysql2.js +15 -0
  292. package/dist/infer/presets/newrelic.d.ts +3 -0
  293. package/dist/infer/presets/newrelic.d.ts.map +1 -0
  294. package/dist/infer/presets/newrelic.js +15 -0
  295. package/dist/infer/presets/node.d.ts +3 -0
  296. package/dist/infer/presets/node.d.ts.map +1 -0
  297. package/dist/infer/presets/node.js +47 -0
  298. package/dist/infer/presets/nodemailer.d.ts +3 -0
  299. package/dist/infer/presets/nodemailer.d.ts.map +1 -0
  300. package/dist/infer/presets/nodemailer.js +50 -0
  301. package/dist/infer/presets/passport-github2.d.ts +3 -0
  302. package/dist/infer/presets/passport-github2.d.ts.map +1 -0
  303. package/dist/infer/presets/passport-github2.js +24 -0
  304. package/dist/infer/presets/passport-google-oauth20.d.ts +3 -0
  305. package/dist/infer/presets/passport-google-oauth20.d.ts.map +1 -0
  306. package/dist/infer/presets/passport-google-oauth20.js +24 -0
  307. package/dist/infer/presets/passport-jwt.d.ts +3 -0
  308. package/dist/infer/presets/passport-jwt.d.ts.map +1 -0
  309. package/dist/infer/presets/passport-jwt.js +15 -0
  310. package/dist/infer/presets/passport.d.ts +3 -0
  311. package/dist/infer/presets/passport.d.ts.map +1 -0
  312. package/dist/infer/presets/passport.js +15 -0
  313. package/dist/infer/presets/pg.d.ts +3 -0
  314. package/dist/infer/presets/pg.d.ts.map +1 -0
  315. package/dist/infer/presets/pg.js +15 -0
  316. package/dist/infer/presets/pino.d.ts +3 -0
  317. package/dist/infer/presets/pino.d.ts.map +1 -0
  318. package/dist/infer/presets/pino.js +15 -0
  319. package/dist/infer/presets/prisma.d.ts +3 -0
  320. package/dist/infer/presets/prisma.d.ts.map +1 -0
  321. package/dist/infer/presets/prisma.js +24 -0
  322. package/dist/infer/presets/sentry.d.ts +3 -0
  323. package/dist/infer/presets/sentry.d.ts.map +1 -0
  324. package/dist/infer/presets/sentry.js +15 -0
  325. package/dist/infer/presets/something.d.ts +4 -0
  326. package/dist/infer/presets/something.d.ts.map +1 -0
  327. package/dist/infer/presets/something.js +29 -0
  328. package/dist/infer/presets/stripe.d.ts +3 -0
  329. package/dist/infer/presets/stripe.d.ts.map +1 -0
  330. package/dist/infer/presets/stripe.js +33 -0
  331. package/dist/infer/presets/typeorm.d.ts +3 -0
  332. package/dist/infer/presets/typeorm.d.ts.map +1 -0
  333. package/dist/infer/presets/typeorm.js +57 -0
  334. package/dist/infer/presets/vitest.d.ts +3 -0
  335. package/dist/infer/presets/vitest.d.ts.map +1 -0
  336. package/dist/infer/presets/vitest.js +13 -0
  337. package/dist/infer/presets/winston.d.ts +3 -0
  338. package/dist/infer/presets/winston.d.ts.map +1 -0
  339. package/dist/infer/presets/winston.js +15 -0
  340. package/dist/infer/presets.d.ts +7 -0
  341. package/dist/infer/presets.d.ts.map +1 -0
  342. package/dist/infer/presets.js +119 -0
  343. package/dist/infer/presets.types.d.ts +16 -0
  344. package/dist/infer/presets.types.d.ts.map +1 -0
  345. package/dist/infer/presets.types.js +1 -0
  346. package/dist/infer/process.env/infer-collector.d.ts +7 -0
  347. package/dist/infer/process.env/infer-collector.d.ts.map +1 -0
  348. package/dist/infer/process.env/infer-collector.js +26 -0
  349. package/dist/infer/report.types.d.ts +57 -0
  350. package/dist/infer/report.types.d.ts.map +1 -0
  351. package/dist/infer/report.types.js +1 -0
  352. package/dist/infer/rules/basic.d.ts +9 -4
  353. package/dist/infer/rules/basic.d.ts.map +1 -1
  354. package/dist/infer/rules/basic.js +31 -17
  355. package/dist/infer/rules/boolean.d.ts +2 -2
  356. package/dist/infer/rules/boolean.d.ts.map +1 -1
  357. package/dist/infer/rules/boolean.js +5 -3
  358. package/dist/infer/rules/duration.d.ts +2 -2
  359. package/dist/infer/rules/duration.d.ts.map +1 -1
  360. package/dist/infer/rules/duration.js +18 -9
  361. package/dist/infer/rules/ip.d.ts +2 -2
  362. package/dist/infer/rules/ip.d.ts.map +1 -1
  363. package/dist/infer/rules/ip.js +5 -3
  364. package/dist/infer/rules/json.d.ts +2 -2
  365. package/dist/infer/rules/json.d.ts.map +1 -1
  366. package/dist/infer/rules/json.js +7 -6
  367. package/dist/infer/rules/key-value.d.ts +3 -0
  368. package/dist/infer/rules/key-value.d.ts.map +1 -0
  369. package/dist/infer/rules/key-value.js +56 -0
  370. package/dist/infer/rules/list.d.ts +2 -4
  371. package/dist/infer/rules/list.d.ts.map +1 -1
  372. package/dist/infer/rules/list.js +56 -165
  373. package/dist/infer/rules/port.d.ts +2 -2
  374. package/dist/infer/rules/port.d.ts.map +1 -1
  375. package/dist/infer/rules/port.js +6 -4
  376. package/dist/infer/rules/url.d.ts +2 -2
  377. package/dist/infer/rules/url.d.ts.map +1 -1
  378. package/dist/infer/rules/url.js +22 -61
  379. package/dist/infer/rules/version.d.ts +2 -2
  380. package/dist/infer/rules/version.d.ts.map +1 -1
  381. package/dist/infer/rules/version.js +5 -3
  382. package/dist/infer/rules.d.ts +5 -0
  383. package/dist/infer/rules.d.ts.map +1 -0
  384. package/dist/infer/rules.js +31 -0
  385. package/dist/infer/rules.types.d.ts +153 -0
  386. package/dist/infer/rules.types.d.ts.map +1 -0
  387. package/dist/infer/rules.types.js +17 -0
  388. package/dist/infer/scripts/official-preset-registry.gen.d.ts +13 -0
  389. package/dist/infer/scripts/official-preset-registry.gen.d.ts.map +1 -0
  390. package/dist/infer/scripts/official-preset-registry.gen.js +154 -0
  391. package/dist/infer/secret-rules/secret.d.ts +3 -0
  392. package/dist/infer/secret-rules/secret.d.ts.map +1 -0
  393. package/dist/infer/secret-rules/secret.js +10 -0
  394. package/dist/infer/secret.d.ts +3 -0
  395. package/dist/infer/secret.d.ts.map +1 -0
  396. package/dist/infer/secret.js +10 -0
  397. package/dist/infer/secret.types.d.ts +6 -0
  398. package/dist/infer/secret.types.d.ts.map +1 -0
  399. package/dist/infer/secret.types.js +4 -0
  400. package/dist/infer/types.d.ts +60 -7
  401. package/dist/infer/types.d.ts.map +1 -1
  402. package/dist/infer/types.js +16 -0
  403. package/dist/llm-kit/context.json.d.ts +1 -1
  404. package/dist/llm-kit/context.json.d.ts.map +1 -1
  405. package/dist/llm-kit/context.json.js +1 -2
  406. package/dist/process/process-collector.d.ts +5 -0
  407. package/dist/process/process-collector.d.ts.map +1 -0
  408. package/dist/process/process-collector.js +34 -0
  409. package/dist/process/process-engine.d.ts +4 -0
  410. package/dist/process/process-engine.d.ts.map +1 -0
  411. package/dist/process/process-engine.js +45 -0
  412. package/dist/process/report.type.d.ts +27 -0
  413. package/dist/process/report.type.d.ts.map +1 -0
  414. package/dist/process/report.type.js +1 -0
  415. package/dist/process/rules/fallback.d.ts +3 -0
  416. package/dist/process/rules/fallback.d.ts.map +1 -0
  417. package/dist/process/rules/fallback.js +26 -0
  418. package/dist/process/rules/process-env-var.d.ts +3 -0
  419. package/dist/process/rules/process-env-var.d.ts.map +1 -0
  420. package/dist/process/rules/process-env-var.js +37 -0
  421. package/dist/process/rules/warn-unknown-var.d.ts +3 -0
  422. package/dist/process/rules/warn-unknown-var.d.ts.map +1 -0
  423. package/dist/process/rules/warn-unknown-var.js +40 -0
  424. package/dist/process/types.d.ts +28 -0
  425. package/dist/process/types.d.ts.map +1 -0
  426. package/dist/process/types.js +1 -0
  427. package/dist/sample/dummy-exporter.d.ts +7 -0
  428. package/dist/sample/dummy-exporter.d.ts.map +1 -0
  429. package/dist/sample/env.dnl.d.ts +29 -386
  430. package/dist/sample/env.dnl.d.ts.map +1 -1
  431. package/dist/sample/env.dnl.js +44 -393
  432. package/dist/sample/main.d.ts +2 -0
  433. package/dist/sample/main.d.ts.map +1 -0
  434. package/dist/sample/main.js +5 -0
  435. package/dist/sample/process-env.example.d.ts +13 -0
  436. package/dist/sample/process-env.example.d.ts.map +1 -0
  437. package/dist/sample/process-env.example.js +56 -0
  438. package/dist/sample/sample-exporter.d.ts +50 -0
  439. package/dist/sample/sample-exporter.d.ts.map +1 -0
  440. package/dist/sample/sample-exporter.js +79 -0
  441. package/dist/schemas/boolean.d.ts +1 -1
  442. package/dist/schemas/boolean.d.ts.map +1 -1
  443. package/dist/schemas/boolean.js +1 -1
  444. package/dist/schemas/common.d.ts +39 -0
  445. package/dist/schemas/common.d.ts.map +1 -0
  446. package/dist/schemas/common.js +1 -0
  447. package/dist/schemas/duration.d.ts +1 -0
  448. package/dist/schemas/duration.d.ts.map +1 -1
  449. package/dist/schemas/duration.js +1 -1
  450. package/dist/schemas/key-value.d.ts +10 -0
  451. package/dist/schemas/key-value.d.ts.map +1 -0
  452. package/dist/schemas/key-value.js +33 -0
  453. package/dist/schemas/list.d.ts +4 -46
  454. package/dist/schemas/list.d.ts.map +1 -1
  455. package/dist/schemas/list.js +1 -36
  456. package/dist/schemas/path.d.ts +2 -2
  457. package/dist/schemas/path.d.ts.map +1 -1
  458. package/dist/schemas/path.js +7 -8
  459. package/dist/schemas/urls.d.ts.map +1 -1
  460. package/dist/schemas/urls.js +8 -1
  461. package/dist/scripts/script-desc.d.ts +6 -0
  462. package/dist/scripts/script-desc.d.ts.map +1 -0
  463. package/dist/scripts/script-desc.js +24 -0
  464. package/dist/utils/read-user-package-json.d.ts +10 -0
  465. package/dist/utils/read-user-package-json.d.ts.map +1 -0
  466. package/dist/utils/read-user-package-json.js +37 -0
  467. package/package.json +47 -6
@@ -0,0 +1,67 @@
1
+ import { DNL_ANNOTATION } from "../report.type.js";
2
+ import { getLinkToVar } from "../../ast-tools/ast-helpers.js";
3
+ import { hasDnlAnnotation } from "../helper.js";
4
+ import { getDefaultEnvValue } from "../../cli/utils/printer.js";
5
+ export const addAnnotationRule = {
6
+ match(usages) {
7
+ // If at least one has no annotation, we need to add the annotation
8
+ return usages.some((u) => !hasDnlAnnotation(u.anchor, undefined));
9
+ },
10
+ async apply(usages, ctx) {
11
+ const issues = [];
12
+ const anchor = usages[0].anchor;
13
+ const old = anchor.getText();
14
+ const indentMatch = old.match(/^\s*/);
15
+ const indent = indentMatch ? indentMatch[0] : "";
16
+ const body = old.trimStart();
17
+ // Build an object to know the comment characteristics
18
+ for (const u of usages) {
19
+ const issue = {
20
+ nodeText: u.node.getText(),
21
+ annotation: null,
22
+ messages: [],
23
+ pos: u.pos,
24
+ };
25
+ switch (u.kind) {
26
+ case "destructured":
27
+ case "static":
28
+ if (u.varName in ctx.envDef.def) {
29
+ issue.annotation = DNL_ANNOTATION.recommendation;
30
+ const link = getLinkToVar(ctx.project, ctx.schemaPath, u.varName);
31
+ const defaultValue = getDefaultEnvValue(ctx.envDef.def[u.varName].schema.def);
32
+ issue.messages.push(`// @see ${u.varName} in your DNL schema : ${link}`);
33
+ if (defaultValue) {
34
+ issue.messages.push(`// default value: ${defaultValue}`);
35
+ }
36
+ }
37
+ else {
38
+ issue.annotation = DNL_ANNOTATION.ignore;
39
+ issue.messages.push(`// process.env.${u.varName} not in your DNL schema`);
40
+ }
41
+ break;
42
+ case "dynamic":
43
+ issue.annotation = DNL_ANNOTATION.dynamic;
44
+ issue.messages.push(`// Dynamic access to process.env prevents variable-level analysis`);
45
+ break;
46
+ case "global":
47
+ issue.annotation = DNL_ANNOTATION.global;
48
+ issue.messages.push(`// Global access to process.env prevents variable-level analysis`);
49
+ break;
50
+ }
51
+ issues.push(issue);
52
+ }
53
+ // Concat all issues to one unique comment (for one statement).
54
+ const lines = [];
55
+ lines.push(`// ${issues.map((issue) => issue.annotation).join(" ")}`);
56
+ // Deduplicate messages
57
+ const messages = [...new Set(issues.flatMap((issue) => issue.messages))];
58
+ for (const message of messages) {
59
+ lines.push(message);
60
+ }
61
+ // Apply indentation to each comment line
62
+ const comment = lines.map((line) => `${indent}${line}`).join("\n");
63
+ // Reinsert the original statement with its indentation
64
+ anchor.replaceWithText(`${comment}\n${indent}${body}`);
65
+ return issues;
66
+ },
67
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const fallbackRule: AnnotateRule;
3
+ //# sourceMappingURL=annotate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotate.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/annotate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,YAAY,EAAE,YA6B1B,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { Node } from "ts-morph";
2
+ import { getLinkToVar } from "../helper.js";
3
+ import { getDefaultEnvValue } from "../../cli/utils/printer.js";
4
+ export const fallbackRule = {
5
+ name: "recommendation",
6
+ match(node) {
7
+ if (node.getText().includes("@dnl-annotation"))
8
+ return false;
9
+ return true;
10
+ },
11
+ async apply(node, ctx) {
12
+ // match() garantit déjà que c'est un PropertyAccessExpression sur process.env
13
+ const varName = node.getName();
14
+ const statement = node.getFirstAncestor((n) => Node.isStatement(n));
15
+ if (statement) {
16
+ const old = statement.getText();
17
+ const link = getLinkToVar(ctx.project, ctx.schemaPath, varName);
18
+ const defaultValue = getDefaultEnvValue(ctx.envDef.def[varName].schema.def);
19
+ let comment = `// @dnl-annotation ${this.name}\n// @see ${varName} in your DNL schema : ${link}`;
20
+ if (defaultValue)
21
+ comment += `\n// default value: ${defaultValue}`;
22
+ statement.replaceWithText(`${comment}\n${old}`);
23
+ }
24
+ return {
25
+ level: "warning",
26
+ message: "unsupported process.env usage",
27
+ action: "comment-added",
28
+ };
29
+ },
30
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const checkAnnotationRule: AnnotateRule;
3
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,eAAO,MAAM,mBAAmB,EAAE,YAwDjC,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { DNL_ANNOTATION } from "../report.type.js";
2
+ import { getDnlAnnotationType, hasDnlAnnotation } from "../helper.js";
3
+ export const checkAnnotationRule = {
4
+ match(processEnvAccesses) {
5
+ function matchOne(pea) {
6
+ if (!hasDnlAnnotation(pea.anchor))
7
+ return true;
8
+ if (getDnlAnnotationType(pea.anchor) === DNL_ANNOTATION.ignore)
9
+ return false;
10
+ return true;
11
+ }
12
+ return processEnvAccesses.some((pea) => matchOne(pea));
13
+ },
14
+ async apply(processEnvAccesses) {
15
+ const issues = [];
16
+ for (let i = 0; i < processEnvAccesses.length; i++) {
17
+ const pea = processEnvAccesses[i];
18
+ const noAnnotationIssue = {
19
+ annotation: null,
20
+ messages: [`No DNL annotation found for ${pea.node.getText()}`],
21
+ checkLevel: "error",
22
+ nodeText: pea.node.getText(),
23
+ };
24
+ const anchor = pea.anchor;
25
+ // No annotation => Error!
26
+ if (!anchor || !hasDnlAnnotation(anchor)) {
27
+ issues.push(noAnnotationIssue);
28
+ continue;
29
+ }
30
+ // If we have an annotation, retrieve it and create the corresponding issue.
31
+ const annotation = getDnlAnnotationType(anchor);
32
+ const issue = {
33
+ nodeText: pea.node.getText(),
34
+ annotation,
35
+ messages: [],
36
+ pos: pea.pos,
37
+ };
38
+ switch (annotation) {
39
+ case null:
40
+ issues.push(noAnnotationIssue);
41
+ break;
42
+ case DNL_ANNOTATION.ignore:
43
+ // Normally this case is filtered out by match before reaching apply.
44
+ // We keep the case to produce an empty/absurd result, but it should not happen.
45
+ issue.checkLevel = "info";
46
+ issues.push(issue);
47
+ break;
48
+ default:
49
+ issue.checkLevel = "warning";
50
+ issues.push(issue);
51
+ break;
52
+ }
53
+ }
54
+ return issues;
55
+ },
56
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const fallbackRule: AnnotateRule;
3
+ //# sourceMappingURL=fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/fallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,YAAY,EAAE,YAoC1B,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { Node } from "ts-morph";
2
+ import { getLinkToVar } from "../helper.js";
3
+ import { getDefaultEnvValue } from "../../cli/utils/printer.js";
4
+ export const fallbackRule = {
5
+ name: "fallback-unsupported-usage",
6
+ match(node) {
7
+ if (node.getText().includes("@dnl-process-annotation"))
8
+ return false;
9
+ return true;
10
+ },
11
+ async apply(node, ctx) {
12
+ // match() garantit déjà que c'est un PropertyAccessExpression sur process.env
13
+ const varName = node.getName();
14
+ //console.log("fallbackRule apply");
15
+ const statement = node.getFirstAncestor((n) => Node.isStatement(n));
16
+ // console.log("sourceFile : ", ctx.sourceFile.getFilePath());
17
+ // console.log("statement : ", statement?.getText());
18
+ if (statement) {
19
+ const old = statement.getText();
20
+ const link = getLinkToVar(ctx.project, ctx.schemaPath, varName);
21
+ const defaultValue = getDefaultEnvValue(ctx.envDef.def[varName].schema.def);
22
+ let comment = `// @dnl-process-annotation ${this.name}\n// @see ${varName} in your DNL schema : ${link}`;
23
+ if (defaultValue)
24
+ comment += `\n// default value: ${defaultValue}`;
25
+ statement.replaceWithText(`${comment}\n${old}`);
26
+ //const result = statement.replaceWithText(`// @dnl-warning unsupported process.env usage\n${old}`);
27
+ // console.log("statement replaced : ", result?.getText());
28
+ console.log("defaultValue : ", defaultValue);
29
+ }
30
+ return {
31
+ level: "warning",
32
+ message: "unsupported process.env usage",
33
+ action: "comment-added",
34
+ };
35
+ },
36
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const warnUnknownVarRule: AnnotateRule;
3
+ //# sourceMappingURL=ignore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/ignore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,eAAO,MAAM,kBAAkB,EAAE,YAuChC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Node } from "ts-morph";
2
+ import { DNL_ANNOTATION } from "../report.type.js";
3
+ import { getAnnotationStatement, hasDnlAnnotation } from "../helper.js";
4
+ export const warnUnknownVarRule = {
5
+ annotation: DNL_ANNOTATION.ignore,
6
+ match(node, ctx) {
7
+ if (!Node.isPropertyAccessExpression(node))
8
+ return false;
9
+ const statement = getAnnotationStatement(node);
10
+ console.log("warnUnknownVarRule this.annotation", this.annotation);
11
+ if (statement && hasDnlAnnotation(statement, this.annotation))
12
+ return false;
13
+ const expr = node.getExpression();
14
+ if (expr.getText() !== "process.env")
15
+ return false;
16
+ // skip when it's a DNL var (defined in schema)
17
+ const varName = node.getName();
18
+ const envDefKeys = Object.keys(ctx.envDef.def);
19
+ if (envDefKeys.includes(varName)) {
20
+ return false;
21
+ }
22
+ console.log("warnUnknownVarRule return true");
23
+ return true;
24
+ },
25
+ async apply(node) {
26
+ // match() already guarantees this is a PropertyAccessExpression on process.env
27
+ const varName = node.getName();
28
+ const statement = getAnnotationStatement(node);
29
+ if (statement) {
30
+ const old = statement.getText();
31
+ statement.replaceWithText(`// @dnl-ignore reason : TODO\n${old}`);
32
+ }
33
+ else {
34
+ console.log("warnUnknownVarRule no statement found");
35
+ }
36
+ return {
37
+ message: `DNL ignore process.env.${varName}`,
38
+ };
39
+ },
40
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const AnnotateEnvVarRule: AnnotateRule;
3
+ //# sourceMappingURL=process-env-var.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-env-var.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/process-env-var.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,eAAO,MAAM,kBAAkB,EAAE,YA0ChC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { Node } from "ts-morph";
2
+ export const AnnotateEnvVarRule = {
3
+ name: "process-env-var",
4
+ match(node) {
5
+ if (!Node.isPropertyAccessExpression(node))
6
+ return false;
7
+ const expr = node.getExpression();
8
+ if (expr.getText() !== "process.env")
9
+ return false;
10
+ const parent = node.getParent();
11
+ // On refuse tout usage plus complexe que l'accès direct
12
+ if (Node.isBinaryExpression(parent) || Node.isConditionalExpression(parent) || Node.isCallExpression(parent)) {
13
+ return false;
14
+ }
15
+ // LIMITER aux types scalaires. et encore .... !
16
+ // // ici
17
+ // // if is dnl var !
18
+ // const varName = node.getName();
19
+ // if (ctx.asserter.def[varName].secret) {
20
+ // return false;
21
+ // }
22
+ return true;
23
+ },
24
+ async apply(node) {
25
+ if (!Node.isPropertyAccessExpression(node)) {
26
+ throw new Error("process-env-var applied on non PropertyAccessExpression");
27
+ }
28
+ const varName = node.getName();
29
+ node.replaceWithText(`env.${varName}`);
30
+ return {
31
+ level: "warning",
32
+ message: "unsupported process.env usage",
33
+ action: "replaced",
34
+ };
35
+ },
36
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const fallbackRule: AnnotateRule;
3
+ //# sourceMappingURL=recommandation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recommandation.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/recommandation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,YAAY,EAAE,YA6B1B,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { DNL_ANNOTATION } from "../report.type.js";
2
+ import { Node } from "ts-morph";
3
+ import { getAnnotationStatement, getLinkToVar, hasDnlAnnotation } from "../helper.js";
4
+ import { getDefaultEnvValue } from "../../cli/utils/printer.js";
5
+ export const fallbackRule = {
6
+ annotation: DNL_ANNOTATION.recommendation,
7
+ match(node) {
8
+ console.log("fallbackRule this.annotation", this.annotation);
9
+ const statement = getAnnotationStatement(node);
10
+ if (statement && hasDnlAnnotation(statement, this.annotation))
11
+ return false;
12
+ return true;
13
+ },
14
+ async apply(node, ctx) {
15
+ // match() already guarantees this is a PropertyAccessExpression on process.env
16
+ const varName = node.getName();
17
+ const statement = node.getFirstAncestor((n) => Node.isStatement(n));
18
+ if (statement) {
19
+ const old = statement.getText();
20
+ const link = getLinkToVar(ctx.project, ctx.schemaPath, varName);
21
+ const defaultValue = getDefaultEnvValue(ctx.envDef.def[varName].schema.def);
22
+ let comment = `// ${this.annotation}\n// @see ${varName} in your DNL schema : ${link}`;
23
+ if (defaultValue)
24
+ comment += `\n// default value: ${defaultValue}`;
25
+ statement.replaceWithText(`${comment}\n${old}`);
26
+ }
27
+ return {
28
+ message: `DNL recommend usage of env.${varName}, instead of process.env.${varName}`,
29
+ };
30
+ },
31
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const removeAnnotationRule: AnnotateRule;
3
+ //# sourceMappingURL=remove-annotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-annotation.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/remove-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,eAAO,MAAM,oBAAoB,EAAE,YAgDlC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { DNL_ANNOTATION } from "../report.type.js";
2
+ import { Node } from "ts-morph";
3
+ import { getAnchor, getDnlAnnotation, hasDnlAnnotation } from "../helper.js";
4
+ export const removeAnnotationRule = {
5
+ match(node) {
6
+ if (!Node.isPropertyAccessExpression(node))
7
+ return false;
8
+ if (node.getExpression().getText() !== "process.env")
9
+ return false;
10
+ const anchor = getAnchor(node);
11
+ if (!anchor)
12
+ return false;
13
+ // pas annoté ? on se tait
14
+ if (!hasDnlAnnotation(anchor, undefined)) {
15
+ return false;
16
+ }
17
+ return true;
18
+ },
19
+ async apply(node) {
20
+ const varName = node.getName();
21
+ const statement = getAnchor(node);
22
+ if (!statement) {
23
+ console.log("No DNL annotation found for process.env.${varName}");
24
+ return { annotation: DNL_ANNOTATION.ignore, message: `No DNL annotation found for process.env.${varName}` };
25
+ }
26
+ const dnlAnnotation = getDnlAnnotation(statement);
27
+ if (!dnlAnnotation) {
28
+ console.log("No DNL annotation found for process.env.${varName}");
29
+ return { annotation: DNL_ANNOTATION.ignore, message: `No DNL annotation found for process.env.${varName}` };
30
+ }
31
+ const { ranges, annotationType } = dnlAnnotation;
32
+ if (!ranges || ranges.length < 1) {
33
+ console.log("No DNL annotation found for process.env.${varName}");
34
+ return { annotation: DNL_ANNOTATION.ignore, message: `No DNL annotation found for process.env.${varName}` };
35
+ }
36
+ // Remplace the whole block of annotations (comments) by _nothing_,
37
+ // to keep only the statement (ex. « const nodeEnv = process.env.NODE_ENV || "development"; »).
38
+ // Do not modify here : the command will apply the removalRange in batch (descending order).
39
+ const first = ranges[0];
40
+ // Include everything up to the beginning of the statement to also delete the empty lines between comments and code.
41
+ const removalRange = { start: first.getPos(), end: statement.getStart() };
42
+ return {
43
+ annotation: annotationType,
44
+ message: `DNL annotation removed for process.env.${varName}`,
45
+ removalRange,
46
+ };
47
+ },
48
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const removeAnnotationRule: AnnotateRule;
3
+ //# sourceMappingURL=remove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/remove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,eAAO,MAAM,oBAAoB,EAAE,YA4ClC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { getDnlAnnotation, hasDnlAnnotation } from "../helper.js";
2
+ export const removeAnnotationRule = {
3
+ match(processEnvAccesses) {
4
+ // If at least one has an annotation, we need to remove it
5
+ if (processEnvAccesses.some((pea) => hasDnlAnnotation(pea.anchor)))
6
+ return true;
7
+ return false;
8
+ },
9
+ async apply(processEnvAccesses) {
10
+ // We want to remove the comments added by the Add rule.
11
+ // Add takes the same parameter as remove.
12
+ // Add builds a single comment for all AnnotateEnvRuleIssue in a group.
13
+ // So we only have one block to remove, the first we find!
14
+ // But we still try to detect all annotations we are going to remove.
15
+ const issues = [];
16
+ let detected = false;
17
+ const hasAnnotation = hasDnlAnnotation(processEnvAccesses[0].anchor);
18
+ const dnlAnnotation = getDnlAnnotation(processEnvAccesses[0].anchor);
19
+ const ranges = dnlAnnotation?.ranges ?? [];
20
+ const first = ranges.reduce((min, r) => (r.getPos() < min.getPos() ? r : min), ranges[0]);
21
+ for (let i = 0; i < processEnvAccesses.length; i++) {
22
+ if (!hasAnnotation || !dnlAnnotation || dnlAnnotation.ranges.length < 1) {
23
+ // We should not be here!
24
+ continue;
25
+ }
26
+ const pea = processEnvAccesses[i];
27
+ const annotation = dnlAnnotation?.annotationTypes?.[i] ?? null;
28
+ const removalRange = { start: first?.getPos() ?? 0, end: pea.anchor.getStart() };
29
+ const issue = {
30
+ nodeText: pea.node.getText(),
31
+ annotation,
32
+ messages: [],
33
+ pos: pea.pos,
34
+ removalRange: detected ? undefined : removalRange,
35
+ };
36
+ issues.push(issue);
37
+ detected = true;
38
+ }
39
+ return issues;
40
+ },
41
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const simpleAnnotationRule: AnnotateRule;
3
+ //# sourceMappingURL=simple-annotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-annotation.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/simple-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,oBAAoB,EAAE,YAiDlC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { DNL_ANNOTATION } from "../report.type.js";
2
+ import { Node } from "ts-morph";
3
+ import { getAnchor, getLinkToVar, hasDnlAnnotation } from "../helper.js";
4
+ import { getDefaultEnvValue } from "../../cli/utils/printer.js";
5
+ export const simpleAnnotationRule = {
6
+ match(node) {
7
+ if (!Node.isPropertyAccessExpression(node))
8
+ return false;
9
+ if (node.getExpression().getText() !== "process.env")
10
+ return false;
11
+ const anchor = getAnchor(node);
12
+ if (!anchor)
13
+ return false;
14
+ // déjà annoté ? on se tait
15
+ if (hasDnlAnnotation(anchor, undefined)) {
16
+ console.log("simpleAnnotationRule already annotated, return false");
17
+ return false;
18
+ }
19
+ return true;
20
+ },
21
+ async apply(node, ctx) {
22
+ // match() already guarantees this is a PropertyAccessExpression on process.env
23
+ const varName = node.getName();
24
+ const statement = getAnchor(node);
25
+ if (!statement)
26
+ throw new Error("No statement found");
27
+ const old = statement.getText();
28
+ const isKnown = varName in ctx.envDef.def;
29
+ let annotation;
30
+ let comment;
31
+ let message;
32
+ if (isKnown) {
33
+ // @dnl-annotation
34
+ annotation = DNL_ANNOTATION.recommendation;
35
+ const link = getLinkToVar(ctx.project, ctx.schemaPath, varName);
36
+ const defaultValue = getDefaultEnvValue(ctx.envDef.def[varName].schema.def);
37
+ comment = `// ${annotation}`;
38
+ if (link)
39
+ comment += `\n// @see ${varName} in your DNL schema : ${link}`;
40
+ if (defaultValue)
41
+ comment += `\n// default value: ${defaultValue}`;
42
+ message = `DNL recommend usage of env.${varName}, instead of process.env.${varName}`;
43
+ }
44
+ else {
45
+ //@dnl-ignore reason : TODO
46
+ annotation = DNL_ANNOTATION.ignore;
47
+ comment = `// ${annotation} reason : TODO`;
48
+ message = `DNL ignore process.env.${varName}`;
49
+ }
50
+ statement.replaceWithText(`${comment}\n${old}`);
51
+ return { annotation, message };
52
+ },
53
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const warnUnknownVarRule: AnnotateRule;
3
+ //# sourceMappingURL=warn-unknown-var.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn-unknown-var.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/warn-unknown-var.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,eAAO,MAAM,kBAAkB,EAAE,YAyChC,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { Node } from "ts-morph";
2
+ export const warnUnknownVarRule = {
3
+ name: "process-env-not-in-schema",
4
+ match(node, ctx) {
5
+ if (!Node.isPropertyAccessExpression(node))
6
+ return false;
7
+ const expr = node.getExpression();
8
+ if (expr.getText() !== "process.env")
9
+ return false;
10
+ // const parent = node.getParent();
11
+ // ici
12
+ // if is not adnl var !
13
+ const varName = node.getName();
14
+ const envDefKeys = Object.keys(ctx.envDef.def);
15
+ if (envDefKeys.includes(varName)) {
16
+ console.log("varName : ", varName + ` is a dnl var => ignored by ${this.name} rule`);
17
+ return false;
18
+ }
19
+ console.log("varName : ", varName + ` is a not => ${this.name} should apply`);
20
+ return true;
21
+ },
22
+ async apply(node) {
23
+ // match() garantit déjà que c'est un PropertyAccessExpression sur process.env
24
+ const varName = node.getName();
25
+ const statement = node.getFirstAncestor((n) => Node.isStatement(n));
26
+ // console.log("sourceFile : ", ctx.sourceFile.getFilePath());
27
+ // console.log("statement : ", statement?.getText());
28
+ if (statement) {
29
+ const old = statement.getText();
30
+ statement.replaceWithText(`// @dnl-process-annotation ${this.name} \n// process.env.${varName} is not declared in env.dnl\n${old}`);
31
+ }
32
+ return {
33
+ level: "warning",
34
+ message: `process.env.${varName} is not declared in env.dnl`,
35
+ action: "comment-added",
36
+ };
37
+ },
38
+ };
@@ -0,0 +1,30 @@
1
+ import type { Project, SourceFile } from "ts-morph";
2
+ import type { AnnotateEnvRuleIssue, AnnotateMode, AnnotateReport, DNLAnnotationType } from "./report.type.js";
3
+ import { EnvDefinition, EnvDefinitionHelper } from "../index.js";
4
+ import { ProcessEnvUsages } from "../ast-tools/ast.types.js";
5
+ export type AnnotateRuleContext = {
6
+ mode: AnnotateMode;
7
+ warnAsError: boolean;
8
+ project: Project;
9
+ sourceFile: SourceFile;
10
+ schemaPath: string;
11
+ envDef: EnvDefinitionHelper<EnvDefinition>;
12
+ report: AnnotateReport;
13
+ };
14
+ export interface AnnotateRule {
15
+ /**
16
+ * Unique rule annotation (used for debug, logs, tests)
17
+ */
18
+ annotation?: DNLAnnotationType;
19
+ /**
20
+ * Return true if this rule can handle the given AST node
21
+ */
22
+ match(usages: ProcessEnvUsages[], ctx: AnnotateRuleContext): boolean;
23
+ /**
24
+ * Apply the rule. Receives all process.env nodes from the same statement.
25
+ * - In check mode: must NOT mutate the AST
26
+ * - In fix mode: MAY mutate the AST
27
+ */
28
+ apply(usages: ProcessEnvUsages[], ctx: AnnotateRuleContext): Promise<AnnotateEnvRuleIssue[]>;
29
+ }
30
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/annotate/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC9G,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAE/B;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC;IAErE;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;CAChG"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { Node, Project, type Statement } from "ts-morph";
2
+ import { ProcessEnvUsages } from "./ast.types.js";
3
+ export declare const getAnchor: (node: Node) => Statement | null;
4
+ /** All process.env accesses grouped by statement (key = statement.getStart()). */
5
+ export declare const groupProcessEnvUsagesByStatementMap: (usages: ProcessEnvUsages[]) => Map<number, ProcessEnvUsages[]>;
6
+ /**
7
+ * Returns the environment variable name for a process.env.X or process.env["X"] node.
8
+ */
9
+ export declare const getProcessEnvVarName: (node: Node) => string | null;
10
+ /**
11
+ * Get the link to a variable in the schema file
12
+ * @param project : the ts-morph project
13
+ * @param schemaPath : the path to the schema file
14
+ * @param varName : the name of the variable to get the link to
15
+ * @returns the link to the variable in the schema file
16
+ */
17
+ export declare const getLinkToVar: (project: Project, schemaPath: string, varName: string) => string | null;
18
+ export declare const getRelativeFilePath: (node: Node) => string;
19
+ //# sourceMappingURL=ast-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-helpers.d.ts","sourceRoot":"","sources":["../../src/ast-tools/ast-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,SAAS,EAA+D,MAAM,UAAU,CAAC;AACtH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,SAAS,GAAI,MAAM,IAAI,KAAG,SAAS,GAAG,IAElD,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,mCAAmC,GAAI,QAAQ,gBAAgB,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAW9G,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,IAAI,KAAG,MAAM,GAAG,IAe1D,CAAC;AAKF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,EAAE,YAAY,MAAM,EAAE,SAAS,MAAM,KAAG,MAAM,GAAG,IA+B7F,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,MAAM,IAAI,KAAG,MAKhD,CAAC"}