@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
package/README.md CHANGED
@@ -8,14 +8,17 @@
8
8
  **dotenv-never-lies** validates, types, and documents your environment variables from a TypeScript / Zod schema.
9
9
  It fails fast, loud, and before production.
10
10
 
11
- ## Why?
11
+ ## Introduction#
12
12
 
13
- Because all of this happens all the time:
13
+ ### Why?
14
+
15
+ ecause all of this happens all the time:
14
16
 
15
17
  - ❌ a missing env variable → runtime crash
16
18
  - ❌ a malformed URL → subtle production bug
17
19
  - ❌ CI was not updated after a new variable → confusing red deployment
18
20
  - ❌ an optimistic `process.env.FOO!` → lying to yourself
21
+ - ❌ dotenv silently overrides duplicate keys
19
22
 
20
23
  And because `.env` files are:
21
24
 
@@ -28,18 +31,19 @@ And because `.env` files are:
28
31
 
29
32
  ---
30
33
 
31
- ## What the library does
34
+ ### What the library does
32
35
 
33
- - ✅ validates environment variables at startup
34
- powered by zod, enables complex transformations (arrays, parsing, coercion…)
35
- - ✅ provides infer .Env to get a first real life dnl schema
36
+ - ✅ validates environment variables at startup
37
+ powered by Zod, enabling complex transformations (arrays, parsing, coercion…)
38
+ - ✅ prevents duplicate environment variables
39
+ - ✅ infers a first real-world DNL schema from an existing `.env`
36
40
  - ✅ provides reliable TypeScript typings
37
41
  - ✅ documents each variable
38
- - ✅ exposes a CLI for CI and humans (dnl export)
42
+ - ✅ exposes a CLI for CI and humans (`dnl export`)
39
43
 
40
44
  ---
41
45
 
42
- ## What dotenv-never-lies is not
46
+ ### What dotenv-never-lies is not
43
47
 
44
48
  This package has a deliberately limited scope.
45
49
 
@@ -69,7 +73,7 @@ that prefer to **fail cleanly at startup** rather than **silently break in produ
69
73
 
70
74
  ---
71
75
 
72
- ## Installation
76
+ ### Installation
73
77
 
74
78
  ```bash
75
79
  npm install @romaintaillandier1978/dotenv-never-lies
@@ -77,7 +81,7 @@ npm install @romaintaillandier1978/dotenv-never-lies
77
81
  yarn add @romaintaillandier1978/dotenv-never-lies
78
82
  ```
79
83
 
80
- ## Dependencies and compatibility
84
+ ### Dependencies and compatibility
81
85
 
82
86
  **[`zod`](https://www.npmjs.com/package/zod)** — dotenv-never-lies exposes Zod schemas in its public API.
83
87
 
@@ -125,6 +129,12 @@ Supported in this order for all CLI commands:
125
129
 
126
130
  3. one of `env.dnl.ts`, `env.dnl.js`, `dnl.config.ts`, `dnl.config.js`
127
131
 
132
+ 4. as you wish, using the `--schema` option
133
+
134
+ ```bash
135
+ dnl infer --schema path/to/my-dnl.ts
136
+ ```
137
+
128
138
  ### define a schema
129
139
 
130
140
  ```typescript
@@ -155,11 +165,11 @@ export default define({
155
165
  });
156
166
  ```
157
167
 
158
- ## Secrets handling
168
+ ### Secrets handling
159
169
 
160
170
  Reminder: dotenv-never-lies is not a secrets manager.
161
171
 
162
- ### declaration in the DNL schema
172
+ **declaration in the DNL schema**
163
173
 
164
174
  A variable is considered secret if and only if it is explicitly marked in the schema with `secret: true`.
165
175
  (`secret: undefined` is equivalent to `secret: false`)
@@ -197,6 +207,8 @@ This separation ensures that validation, runtime usage and configuration export
197
207
 
198
208
  ## Runtime usage
199
209
 
210
+ ### assert: validate variables at runtime
211
+
200
212
  ```typescript
201
213
  import envDef from "./env.dnl";
202
214
 
@@ -224,10 +236,9 @@ Result:
224
236
  If a variable is missing or invalid → the process exits immediately.
225
237
  This is intentional.
226
238
 
227
- ## Avoid `process.env` in application code
239
+ ### Avoid `process.env` in application code
228
240
 
229
- Once the schema is loaded, environment variables
230
- must be accessed exclusively via the `ENV` object.
241
+ Once the schema is loaded, environment variables must be accessed exclusively via the `ENV` object.
231
242
 
232
243
  This guarantees:
233
244
 
@@ -235,17 +246,13 @@ This guarantees:
235
246
  - validated values
236
247
  - a single entry point for configuration
237
248
 
238
- To identify residual `process.env` usages in your codebase, a simple search tool is enough:
239
-
240
- ```bash
241
- grep -R "process\.env" src
242
- ```
249
+ To identify residual `process.env` usages in your codebase, use the `dnl annotate` [annotate command](docs/commands/annotate.md) for more details.
243
250
 
244
251
  Choosing to refactor (or not) those usages depends on context and is intentionally left to the developer.
245
252
 
246
253
  ## CLI
247
254
 
248
- The CLI lets you validate, load, generate, export, and document environment variables from a `dotenv-never-lies` schema.
255
+ The CLI lets you infer, types, assert, export, and explain environment variables to/from a `dotenv-never-lies` schema.
249
256
 
250
257
  It is designed to be used:
251
258
 
@@ -265,17 +272,58 @@ It is designed to be used:
265
272
  | 3 | Environment validation failed |
266
273
  | 4 | Error during export |
267
274
 
268
- ### assert: Validate a `.env` file (CI-friendly)
275
+ ### infer: discover a .envfile, and generate a schema from an existing .env
276
+
277
+ Generate a DNL schema from an existing `.env` file.
278
+
279
+ ```bash
280
+ dnl infer --source .env
281
+ ```
282
+
283
+ Useful for migrating an existing project
284
+
285
+ → [Read infer documentation](docs/commands/infer.md)
286
+
287
+ ### types: generate a TypeScript declaration file from an existing DNL schema
288
+
289
+ Generates a `./src/types/env.dnl.d.ts` file from the `env.dnl.ts` file.
290
+
291
+ ```bash
292
+ dnl types
293
+ ```
294
+
295
+ Useful for getting IntelliSense _after_ finalizing your DNL schema completion.
296
+
297
+ → [Read infer documentation](docs/commands/types.md)
298
+
299
+ ### annotate: Identify and manage `process.env` usages
300
+
301
+ Scans the codebase and adds contextual annotations to help migrate from `process.env` to DNL-validated variables.
302
+
303
+ ```bash
304
+ dnl annotate
305
+ ```
306
+
307
+ - Use locally to discover and progressively replace legacy `process.env` usages.
308
+ - Use `dnl annotate --check` in CI or Git hooks (pre-commit, post-merge) to prevent introducing new unreviewed `process.env` accesses.
309
+
310
+ → [Read annotate documentation](docs/commands/annotate.md)
311
+
312
+ ### assert: Validate environement variables (runtime, CI-friendly)
269
313
 
270
314
  Validates variables without injecting them into `process.env`.
271
315
 
272
316
  ```bash
273
- dnl assert --source .env --schema env.dnl.ts
317
+ dnl assert --source .env
274
318
  ```
275
319
 
276
320
  Without `--source`, `dnl assert` validates `process.env`.
277
321
  This is the recommended mode when variables are injected by the runtime or CI.
278
322
 
323
+ ```bash
324
+ dnl assert
325
+ ```
326
+
279
327
  → fails if:
280
328
 
281
329
  - a variable is missing
@@ -288,7 +336,7 @@ Initialize a documented `.env` from the schema.
288
336
  Do not read any environment variables
289
337
 
290
338
  ```bash
291
- dnl init --schema env.dnl.ts --out .env
339
+ dnl init --out .env
292
340
  ```
293
341
 
294
342
  Useful for:
@@ -297,18 +345,6 @@ Useful for:
297
345
  - sharing a template
298
346
  - avoiding obsolete `.env.example` files
299
347
 
300
- ### infer: discover a .envfile, and generate a schema from an existing .env
301
-
302
- Generate a DNL schema from an existing `.env` file.
303
-
304
- ```bash
305
- dnl infer --source .env
306
- ```
307
-
308
- Useful for migrating an existing project
309
-
310
- → [Read infer documentation](docs/commands/infer.md)
311
-
312
348
  ### explain: Display variables documentation
313
349
 
314
350
  Displays the list of known variables and their description.
@@ -332,73 +368,25 @@ The `export` command transforms variables validated by the schema
332
368
  into formats directly consumable by other tools (Docker, CI, Kubernetes, scripts…).
333
369
 
334
370
  The schema remains the source of truth.
335
- Values are validated before export.
336
-
337
- ```bash
338
- dnl export <format>
339
- ```
371
+ Values are validated before export, and validated AND raw values are passed to the exporter.
340
372
 
341
- By default, values are read from `process.env`.
342
- A `.env` file can be provided via `--source`.
343
-
344
- Examples:
345
- Export environment variables as JSON from a `.env` file
346
-
347
- ```bash
348
- dnl export json --source .env
349
- ```
350
-
351
- Clean a `.env` file (remove comments and extraneous lines)
373
+ Example:
352
374
 
353
375
  ```bash
354
- dnl export env --source .env --out .env.clean
355
- dnl export env --source .env --out .env --force
376
+ dnl export docker-args
356
377
  ```
357
378
 
358
- Export variables as `docker-args`
379
+ Example output:
359
380
 
360
381
  ```bash
361
- dnl export docker-args --source .env
382
+ -e NODE_ENV=test -e NODE_PORT=3000 -e FRONT_URL=https://example.com
362
383
  ```
363
384
 
364
- Result:
385
+ See DNL documentation for more formats and options :
386
+ → [Read export documentation](docs/commands/export.md)
365
387
 
366
- ```bash
367
- -e "NODE_ENV=production" -e "NODE_PORT=3000"
368
- ```
369
-
370
- Export for GitHub Actions (variables)
371
-
372
- ```bash
373
- dnl export github-env
374
- ```
375
-
376
- Result:
377
-
378
- ```bash
379
- printf '%s\n' "NODE_ENV=production" >> $GITHUB_ENV
380
- printf '%s\n' "NODE_PORT=3000" >> $GITHUB_ENV
381
- ```
382
-
383
- There are a few more formats and options (see CLI docs `dnl export --help`).
384
-
385
- ## export types : Exporting TypeScript types
386
-
387
- `dnl export types` generates a `.d.ts` file describing the **static contract** of your environment variables.
388
-
389
- This file is intentionally **conservative**.
390
-
391
- ### Transformed variables
392
-
393
- If a variable uses a Zod `transform`, the exported type always reflects the **input type**, not the runtime output.
394
-
395
- In that case:
396
-
397
- - a warning is emitted in the CLI
398
- - the generated type is annotated with `@dnl-transform`
399
- - the runtime value returned by `assert()` may differ
400
-
401
- This is a deliberate design choice to avoid lying to TypeScript.
388
+ Export command is based on a plugin system, see how to implement your own exporter :
389
+ [Read export plugins documentation](docs/commands/export-plugins.md)
402
390
 
403
391
  ## Real-life usage
404
392
 
@@ -414,6 +402,7 @@ Add `.dnl/` to your `.gitignore`.
414
402
  Using **dotenv-never-lies** via Git hooks is strongly recommended:
415
403
 
416
404
  - **pre-commit**: prevents committing if the local configuration is not compliant with the schema
405
+ - **pre-commit**: prevents committing if local process.env is used (without annotation)
417
406
  - **post-merge**: immediately detects schema changes impacting the local environment
418
407
 
419
408
  The goal is simple:
@@ -436,11 +425,13 @@ mkdir -p .githooks
436
425
  cat > .githooks/pre-commit <<'EOF'
437
426
  #!/bin/sh
438
427
  yarn dnl assert --source .env
428
+ yarn dnl annotate --check --warn-as-error
439
429
  EOF
440
430
 
441
431
  cat > .githooks/post-merge <<'EOF'
442
432
  #!/bin/sh
443
433
  yarn dnl assert --source .env || true
434
+ yarn dnl annotate --check --warn-as-error || true
444
435
  EOF
445
436
 
446
437
  chmod +x .githooks/pre-commit .githooks/post-merge
@@ -533,14 +524,6 @@ This validates the environment before startup, without changing runtime behavior
533
524
 
534
525
  > This is optional. It does not replace runtime validation.
535
526
 
536
- **Intellisens and JSdoc for env vars**
537
-
538
- After using `dnl export types` and importing the generated file, you get strong typing, auto-completion, IntelliSense and JSDoc for each environment variable.
539
-
540
- ![IntelliSense and JSDoc for environment variables](docs/images/env-intellisense.png)
541
-
542
- > IntelliSense and JSDoc generated from the DNL schema after `dnl export types`.
543
-
544
527
  ## Common issues / Troubleshooting
545
528
 
546
529
  ### TypeScript projects with `rootDir: "src"`
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=annotate-collector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotate-collector.d.ts","sourceRoot":"","sources":["../../src/annotate/annotate-collector.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ // import { Node, SourceFile } from "ts-morph";
2
+ // import { getAnchor } from "../ast-tools/ast-helpers.js";
3
+ // import { ProcessEnvUsages } from "../ast-tools/ast.types.js";
4
+ export {};
5
+ // export const collectProcessEnvUsages = (sourceFile: SourceFile): ProcessEnvUsages[] => {
6
+ // const accesses: ProcessEnvUsages[] = [];
7
+ // const relativeFilePath = sourceFile.getFilePath();
8
+ // for (const node of sourceFile.getDescendants()) {
9
+ // const pos = node.getSourceFile().getLineAndColumnAtPos(node.getStart());
10
+ // const anchor = getAnchor(node);
11
+ // if (!anchor) continue;
12
+ // // process.env.X
13
+ // if (Node.isPropertyAccessExpression(node)) {
14
+ // const expr = node.getExpression();
15
+ // // process.env.X
16
+ // if (expr.getText() === "process.env") {
17
+ // accesses.push({ node, kind: "static", varName: node.getName(), anchor, relativeFilePath, pos });
18
+ // continue;
19
+ // }
20
+ // // process.env (global access) — only if it is not a sub-node of process.env.X or process.env[...]
21
+ // if (Node.isIdentifier(expr) && expr.getText() === "process" && node.getName() === "env") {
22
+ // const parent = node.getParent();
23
+ // const isSubNodeOfSpecificAccess = parent && (Node.isPropertyAccessExpression(parent) || Node.isElementAccessExpression(parent));
24
+ // if (!isSubNodeOfSpecificAccess) {
25
+ // accesses.push({ node, kind: "global", anchor, relativeFilePath, pos });
26
+ // }
27
+ // continue;
28
+ // }
29
+ // }
30
+ // // process.env["X"] | process.env[key]
31
+ // if (Node.isElementAccessExpression(node)) {
32
+ // const expr = node.getExpression();
33
+ // if (expr.getText() === "process.env") {
34
+ // const arg = node.getArgumentExpression();
35
+ // // process.env["X"]
36
+ // if (Node.isStringLiteral(arg)) {
37
+ // accesses.push({ node, kind: "static", varName: arg.getLiteralText(), anchor, relativeFilePath, pos });
38
+ // }
39
+ // // process.env[key]
40
+ // else {
41
+ // accesses.push({ node, kind: "dynamic", anchor, relativeFilePath, pos });
42
+ // }
43
+ // continue;
44
+ // }
45
+ // }
46
+ // }
47
+ // return accesses;
48
+ // };
@@ -0,0 +1,8 @@
1
+ import { AnnotateRuleContext } from "./types.js";
2
+ import { ProcessEnvUsages } from "../ast-tools/ast.types.js";
3
+ /**
4
+ * Processes a statement: all nodes are process.env usages from the same statement.
5
+ * A single issue is produced per statement.
6
+ */
7
+ export declare const annotateEngine: (accesses: ProcessEnvUsages[], ctx: AnnotateRuleContext) => Promise<void>;
8
+ //# sourceMappingURL=annotate-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotate-engine.d.ts","sourceRoot":"","sources":["../../src/annotate/annotate-engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAI/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAM7D;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAU,UAAU,gBAAgB,EAAE,EAAE,KAAK,mBAAmB,KAAG,OAAO,CAAC,IAAI,CAwCzG,CAAC"}
@@ -0,0 +1,52 @@
1
+ import path from "node:path";
2
+ import { addAnnotationRule } from "./rules/add.js";
3
+ import { removeAnnotationRule } from "./rules/remove.js";
4
+ import { checkAnnotationRule } from "./rules/check.js";
5
+ const RULES_ANNOTATE = [addAnnotationRule];
6
+ const RULES_REMOVE = [removeAnnotationRule];
7
+ const RULES_CHECK = [checkAnnotationRule];
8
+ /**
9
+ * Processes a statement: all nodes are process.env usages from the same statement.
10
+ * A single issue is produced per statement.
11
+ */
12
+ export const annotateEngine = async (accesses, ctx) => {
13
+ if (accesses.length === 0)
14
+ return;
15
+ const rules = ctx.mode === "remove" ? RULES_REMOVE : ctx.mode === "check" ? RULES_CHECK : RULES_ANNOTATE;
16
+ for (const rule of rules) {
17
+ if (!rule.match(accesses, ctx))
18
+ continue;
19
+ // Capture position and filePath before apply(): apply() may modify the AST
20
+ const filePath = path.relative(process.cwd(), ctx.sourceFile.getFilePath());
21
+ const issues = await rule.apply(accesses, ctx);
22
+ for (const issue of issues) {
23
+ ctx.report.issues.push({
24
+ filePath,
25
+ ...issue,
26
+ });
27
+ ctx.report.summary.accessesProcessed++;
28
+ switch (ctx.mode) {
29
+ case "remove":
30
+ ctx.report.summary.commentsRemoved++;
31
+ break;
32
+ case "check":
33
+ if (issue.checkLevel === "error") {
34
+ ctx.report.summary.checkErrors++;
35
+ }
36
+ else if (issue.checkLevel === "warning") {
37
+ if (ctx.warnAsError) {
38
+ ctx.report.summary.checkErrors++;
39
+ }
40
+ else {
41
+ ctx.report.summary.checkWarnings++;
42
+ }
43
+ }
44
+ break;
45
+ case "add":
46
+ ctx.report.summary.commentsAdded++;
47
+ break;
48
+ }
49
+ }
50
+ return;
51
+ }
52
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=annotate-remove-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotate-remove-engine.d.ts","sourceRoot":"","sources":["../../src/annotate/annotate-remove-engine.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import { Node } from "ts-morph";
2
+ import type { CommentRange } from "ts-morph";
3
+ import { DNLAnnotationType } from "./report.type.js";
4
+ /**
5
+ * Check if the statement has a DNL annotation
6
+ * @param statement : the statement to check
7
+ * @param annotation : the annotation to check (optional). If undefined, check for any DNL annotation.
8
+ * @returns true if the statement has a DNL annotation, false otherwise
9
+ */
10
+ export declare const hasDnlAnnotation: (statement: Node, annotation?: DNLAnnotationType | undefined) => boolean;
11
+ /**
12
+ * Get the DNL annotation of the statement
13
+ * @param statement : the statement to check
14
+ * @returns the DNL annotation of the statement, or null if no annotation is found
15
+ */
16
+ export declare const getDnlAnnotation: (statement: Node) => {
17
+ ranges: CommentRange[];
18
+ annotationTypes: DNLAnnotationType[] | null;
19
+ } | null;
20
+ /**
21
+ * Get the DNL annotation of the statement
22
+ * @param statement : the statement to check
23
+ * @returns the DNL annotation of the statement, or null if no annotation is found
24
+ */
25
+ export declare const getDnlAnnotationType: (statement: Node) => DNLAnnotationType | null;
26
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/annotate/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAkB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,IAAI,EAAE,aAAY,iBAAiB,GAAG,SAAqB,KAAG,OAQzG,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,IAAI,KAAG;IAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,eAAe,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAA;CAAE,GAAG,IA4B5H,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,WAAW,IAAI,KAAG,iBAAiB,GAAG,IAqB1E,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { DNL_ANNOTATION } from "./report.type.js";
2
+ /**
3
+ * Check if the statement has a DNL annotation
4
+ * @param statement : the statement to check
5
+ * @param annotation : the annotation to check (optional). If undefined, check for any DNL annotation.
6
+ * @returns true if the statement has a DNL annotation, false otherwise
7
+ */
8
+ export const hasDnlAnnotation = (statement, annotation = undefined) => {
9
+ const ranges = statement.getLeadingCommentRanges();
10
+ if (!ranges || ranges.length < 1)
11
+ return false;
12
+ if (annotation) {
13
+ return ranges.some((c) => c.getText().includes(annotation));
14
+ }
15
+ return ranges.some((c) => Object.values(DNL_ANNOTATION).some((a) => c.getText().includes(a)));
16
+ };
17
+ /**
18
+ * Get the DNL annotation of the statement
19
+ * @param statement : the statement to check
20
+ * @returns the DNL annotation of the statement, or null if no annotation is found
21
+ */
22
+ export const getDnlAnnotation = (statement) => {
23
+ const ranges = statement.getLeadingCommentRanges();
24
+ // if there are other comments above the dnl annotation, we ignore them (to not delete them, they are not ours)
25
+ while (ranges.length > 0 && !ranges[0].getText().includes("@dnl-")) {
26
+ ranges.shift();
27
+ }
28
+ if (ranges.length < 1)
29
+ return null;
30
+ // Collect annotations in the order of their first occurrence in the text
31
+ const annotationTypes = [];
32
+ for (const range of ranges) {
33
+ const text = range.getText();
34
+ const withPosition = [];
35
+ for (const annotation of Object.values(DNL_ANNOTATION)) {
36
+ const index = text.indexOf(annotation);
37
+ if (index !== -1) {
38
+ withPosition.push({ annotation, index });
39
+ }
40
+ }
41
+ withPosition.sort((a, b) => a.index - b.index);
42
+ for (const { annotation } of withPosition) {
43
+ annotationTypes.push(annotation);
44
+ }
45
+ }
46
+ // We know annotationType is not null here (passed through a rule's match).
47
+ // Set a default in fallback, but this should not happen.
48
+ return { ranges, annotationTypes };
49
+ };
50
+ /**
51
+ * Get the DNL annotation of the statement
52
+ * @param statement : the statement to check
53
+ * @returns the DNL annotation of the statement, or null if no annotation is found
54
+ */
55
+ export const getDnlAnnotationType = (statement) => {
56
+ const ranges = statement.getLeadingCommentRanges();
57
+ // if there are other comments above the dnl annotation, we ignore them (to not delete them, they are not ours)
58
+ while (ranges.length > 0 && !ranges[0].getText().includes("@dnl-")) {
59
+ ranges.shift();
60
+ }
61
+ if (ranges.length < 1)
62
+ return null;
63
+ for (const range of ranges) {
64
+ const text = range.getText();
65
+ let earliest = null;
66
+ for (const annotation of Object.values(DNL_ANNOTATION)) {
67
+ const index = text.indexOf(annotation);
68
+ if (index !== -1 && (earliest === null || index < earliest.index)) {
69
+ earliest = { annotation, index };
70
+ }
71
+ }
72
+ if (earliest !== null)
73
+ return earliest.annotation;
74
+ }
75
+ return null;
76
+ };
@@ -0,0 +1,43 @@
1
+ export declare const DNL_ANNOTATION: {
2
+ readonly recommendation: "@dnl-recommendation";
3
+ readonly ignore: "@dnl-ignore";
4
+ readonly dynamic: "@dnl-dynamic-access";
5
+ readonly global: "@dnl-global-access";
6
+ readonly unknown: "@dnl-unknown";
7
+ };
8
+ export type DNLAnnotationType = (typeof DNL_ANNOTATION)[keyof typeof DNL_ANNOTATION];
9
+ export type RemovalRange = {
10
+ start: number;
11
+ end: number;
12
+ };
13
+ export type CheckLevel = "error" | "warning" | "info";
14
+ export type AnnotateEnvRuleIssue = {
15
+ nodeText: string;
16
+ annotation: DNLAnnotationType | null;
17
+ messages: string[];
18
+ pos?: {
19
+ line: number;
20
+ column: number;
21
+ };
22
+ removalRange?: RemovalRange;
23
+ checkLevel?: CheckLevel;
24
+ };
25
+ export type AnnotateIssue = AnnotateEnvRuleIssue & {
26
+ filePath: string;
27
+ };
28
+ export type AnnotateSummary = {
29
+ filesScanned: number;
30
+ accessesProcessed: number;
31
+ commentsAdded: number;
32
+ commentsRemoved: number;
33
+ checkErrors: number;
34
+ checkWarnings: number;
35
+ };
36
+ export type AnnotateMode = "check" | "remove" | "add";
37
+ export type AnnotateReport = {
38
+ type: "annotate";
39
+ mode: AnnotateMode;
40
+ issues: AnnotateIssue[];
41
+ summary: AnnotateSummary;
42
+ };
43
+ //# sourceMappingURL=report.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.type.d.ts","sourceRoot":"","sources":["../../src/annotate/report.type.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAErF,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACrC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,CAAC,EAAE,UAAU,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,oBAAoB,GAAG;IAC/C,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,EAAE,eAAe,CAAC;CAC5B,CAAC"}
@@ -0,0 +1,7 @@
1
+ export const DNL_ANNOTATION = {
2
+ recommendation: "@dnl-recommendation",
3
+ ignore: "@dnl-ignore",
4
+ dynamic: "@dnl-dynamic-access",
5
+ global: "@dnl-global-access",
6
+ unknown: "@dnl-unknown",
7
+ };
@@ -0,0 +1,3 @@
1
+ import { AnnotateRule } from "../types.js";
2
+ export declare const addAnnotationRule: AnnotateRule;
3
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,iBAAiB,EAAE,YAqE/B,CAAC"}