@romaintaillandier1978/dotenv-never-lies 1.5.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 (395) hide show
  1. package/README.md +77 -96
  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.map +1 -1
  66. package/dist/cli/commands/assert.js +1 -0
  67. package/dist/cli/commands/explain.d.ts.map +1 -1
  68. package/dist/cli/commands/explain.js +2 -0
  69. package/dist/cli/commands/export.d.ts +5 -30
  70. package/dist/cli/commands/export.d.ts.map +1 -1
  71. package/dist/cli/commands/export.js +20 -326
  72. package/dist/cli/commands/infer.d.ts +2 -2
  73. package/dist/cli/commands/infer.d.ts.map +1 -1
  74. package/dist/cli/commands/infer.js +186 -48
  75. package/dist/cli/commands/init.d.ts.map +1 -1
  76. package/dist/cli/commands/init.js +2 -0
  77. package/dist/cli/commands/process-check.d.ts +7 -0
  78. package/dist/cli/commands/process-check.d.ts.map +1 -0
  79. package/dist/cli/commands/process-check.js +6 -0
  80. package/dist/cli/commands/process-fix.d.ts +9 -0
  81. package/dist/cli/commands/process-fix.d.ts.map +1 -0
  82. package/dist/cli/commands/process-fix.js +58 -0
  83. package/dist/cli/commands/types.d.ts +14 -0
  84. package/dist/cli/commands/types.d.ts.map +1 -0
  85. package/dist/cli/commands/types.js +56 -0
  86. package/dist/cli/index.d.ts.map +1 -1
  87. package/dist/cli/index.js +224 -237
  88. package/dist/cli/utils/infer-rule-engine.d.ts +3 -2
  89. package/dist/cli/utils/infer-rule-engine.d.ts.map +1 -1
  90. package/dist/cli/utils/infer-rule-engine.js +23 -18
  91. package/dist/cli/utils/load-schema.d.ts.map +1 -1
  92. package/dist/cli/utils/load-schema.js +1 -0
  93. package/dist/cli/utils/printer.d.ts.map +1 -1
  94. package/dist/cli/utils/printer.js +9 -9
  95. package/dist/cli/utils/report.d.ts +15 -0
  96. package/dist/cli/utils/report.d.ts.map +1 -0
  97. package/dist/cli/utils/report.js +173 -0
  98. package/dist/cli/utils/resolve-schema.d.ts.map +1 -1
  99. package/dist/cli/utils/valid-identifier.d.ts +3 -0
  100. package/dist/cli/utils/valid-identifier.d.ts.map +1 -0
  101. package/dist/cli/utils/valid-identifier.js +9 -0
  102. package/dist/core.d.ts +6 -5
  103. package/dist/core.d.ts.map +1 -1
  104. package/dist/core.js +1 -1
  105. package/dist/dnl-config.d.ts.map +1 -1
  106. package/dist/dnl-config.js +4 -2
  107. package/dist/errors.d.ts +5 -1
  108. package/dist/errors.d.ts.map +1 -1
  109. package/dist/errors.js +6 -0
  110. package/dist/export/export.types.d.ts +87 -0
  111. package/dist/export/export.types.d.ts.map +1 -0
  112. package/dist/export/export.types.js +8 -0
  113. package/dist/export/exporters/docker-args.exporter.d.ts +9 -0
  114. package/dist/export/exporters/docker-args.exporter.d.ts.map +1 -0
  115. package/dist/export/exporters/docker-args.exporter.js +33 -0
  116. package/dist/export/exporters/docker-env.exporter.d.ts +8 -0
  117. package/dist/export/exporters/docker-env.exporter.d.ts.map +1 -0
  118. package/dist/export/exporters/docker-env.exporter.js +19 -0
  119. package/dist/export/exporters/env.exporter.d.ts +8 -0
  120. package/dist/export/exporters/env.exporter.d.ts.map +1 -0
  121. package/dist/export/exporters/env.exporter.js +19 -0
  122. package/dist/export/exporters/github-env.exporter.d.ts +8 -0
  123. package/dist/export/exporters/github-env.exporter.d.ts.map +1 -0
  124. package/dist/export/exporters/github-env.exporter.js +15 -0
  125. package/dist/export/exporters/github-secret.exporter.d.ts +12 -0
  126. package/dist/export/exporters/github-secret.exporter.d.ts.map +1 -0
  127. package/dist/export/exporters/github-secret.exporter.js +38 -0
  128. package/dist/export/exporters/gitlab-env.exporter.d.ts +9 -0
  129. package/dist/export/exporters/gitlab-env.exporter.d.ts.map +1 -0
  130. package/dist/export/exporters/gitlab-env.exporter.js +25 -0
  131. package/dist/export/exporters/index.d.ts +12 -0
  132. package/dist/export/exporters/index.d.ts.map +1 -0
  133. package/dist/export/exporters/index.js +11 -0
  134. package/dist/export/exporters/js.exporter.d.ts +9 -0
  135. package/dist/export/exporters/js.exporter.d.ts.map +1 -0
  136. package/dist/export/exporters/js.exporter.js +24 -0
  137. package/dist/export/exporters/json.exporter.d.ts +12 -0
  138. package/dist/export/exporters/json.exporter.d.ts.map +1 -0
  139. package/dist/export/exporters/json.exporter.js +20 -0
  140. package/dist/export/exporters/k8s-configmap.exporter.d.ts +12 -0
  141. package/dist/export/exporters/k8s-configmap.exporter.d.ts.map +1 -0
  142. package/dist/export/exporters/k8s-configmap.exporter.js +37 -0
  143. package/dist/export/exporters/k8s-secret.exporter.d.ts +12 -0
  144. package/dist/export/exporters/k8s-secret.exporter.d.ts.map +1 -0
  145. package/dist/export/exporters/k8s-secret.exporter.js +35 -0
  146. package/dist/export/exporters/shared.d.ts +12 -0
  147. package/dist/export/exporters/shared.d.ts.map +1 -0
  148. package/dist/export/exporters/shared.js +35 -0
  149. package/dist/export/exporters/ts.exporter copy.d.ts +12 -0
  150. package/dist/export/exporters/ts.exporter copy.d.ts.map +1 -0
  151. package/dist/export/exporters/ts.exporter copy.js +25 -0
  152. package/dist/export/exporters/ts.exporter.d.ts +12 -0
  153. package/dist/export/exporters/ts.exporter.d.ts.map +1 -0
  154. package/dist/export/exporters/ts.exporter.js +25 -0
  155. package/dist/export/index.d.ts +3 -0
  156. package/dist/export/index.d.ts.map +1 -0
  157. package/dist/export/index.js +2 -0
  158. package/dist/export/registry.d.ts +17 -0
  159. package/dist/export/registry.d.ts.map +1 -0
  160. package/dist/export/registry.js +104 -0
  161. package/dist/export/shared.d.ts +31 -0
  162. package/dist/export/shared.d.ts.map +1 -0
  163. package/dist/export/shared.js +118 -0
  164. package/dist/index.d.ts +1 -0
  165. package/dist/index.d.ts.map +1 -1
  166. package/dist/index.js +6 -1
  167. package/dist/infer/__tests__/port-vs-version.test.js +1 -1
  168. package/dist/infer/__tests__/rules/basic.test.js +6 -6
  169. package/dist/infer/__tests__/rules/duration.test.js +2 -1
  170. package/dist/infer/__tests__/rules/json.test.js +1 -1
  171. package/dist/infer/__tests__/rules/url.test.js +2 -2
  172. package/dist/infer/__tests__/rules/version.test.js +1 -1
  173. package/dist/infer/cross-rules/secret-non-string.d.ts +1 -1
  174. package/dist/infer/cross-rules/secret-non-string.d.ts.map +1 -1
  175. package/dist/infer/cross-rules/secret-non-string.js +6 -3
  176. package/dist/infer/cross.d.ts +5 -0
  177. package/dist/infer/cross.d.ts.map +1 -0
  178. package/dist/infer/cross.js +16 -0
  179. package/dist/infer/cross.types.d.ts +30 -0
  180. package/dist/infer/cross.types.d.ts.map +1 -0
  181. package/dist/infer/cross.types.js +1 -0
  182. package/dist/infer/generated/basic.d.ts +1 -1
  183. package/dist/infer/generated/boolean.d.ts +1 -1
  184. package/dist/infer/generated/duration.d.ts +1 -1
  185. package/dist/infer/generated/ip.d.ts +1 -1
  186. package/dist/infer/generated/json.d.ts +1 -1
  187. package/dist/infer/generated/key-value.d.ts +1 -1
  188. package/dist/infer/generated/list.d.ts +1 -1
  189. package/dist/infer/generated/port.d.ts +1 -1
  190. package/dist/infer/generated/url.d.ts +1 -1
  191. package/dist/infer/generated/version.d.ts +1 -1
  192. package/dist/infer/helpers.d.ts +1 -2
  193. package/dist/infer/helpers.d.ts.map +1 -1
  194. package/dist/infer/helpers.js +0 -4
  195. package/dist/infer/heuristic.d.ts +4 -0
  196. package/dist/infer/heuristic.d.ts.map +1 -0
  197. package/dist/infer/heuristic.js +56 -0
  198. package/dist/infer/heuristic.types.d.ts +54 -0
  199. package/dist/infer/heuristic.types.d.ts.map +1 -0
  200. package/dist/infer/heuristic.types.js +1 -0
  201. package/dist/infer/heuristicRules.d.ts +6 -0
  202. package/dist/infer/heuristicRules.d.ts.map +1 -0
  203. package/dist/infer/heuristicRules.js +31 -0
  204. package/dist/infer/infer.types.d.ts +83 -0
  205. package/dist/infer/infer.types.d.ts.map +1 -0
  206. package/dist/infer/infer.types.js +17 -0
  207. package/dist/infer/official-preset-registry.d.ts +2 -2
  208. package/dist/infer/official-preset-registry.d.ts.map +1 -1
  209. package/dist/infer/presets/agenda.d.ts +2 -2
  210. package/dist/infer/presets/agenda.d.ts.map +1 -1
  211. package/dist/infer/presets/agenda.js +1 -1
  212. package/dist/infer/presets/amqplib.d.ts +2 -2
  213. package/dist/infer/presets/amqplib.d.ts.map +1 -1
  214. package/dist/infer/presets/amqplib.js +1 -1
  215. package/dist/infer/presets/aws-sdk.d.ts +2 -2
  216. package/dist/infer/presets/aws-sdk.d.ts.map +1 -1
  217. package/dist/infer/presets/aws-sdk_client-s3.d.ts +2 -2
  218. package/dist/infer/presets/aws-sdk_client-s3.d.ts.map +1 -1
  219. package/dist/infer/presets/bcrypt.d.ts +2 -2
  220. package/dist/infer/presets/bcrypt.d.ts.map +1 -1
  221. package/dist/infer/presets/bull.d.ts +2 -2
  222. package/dist/infer/presets/bull.d.ts.map +1 -1
  223. package/dist/infer/presets/bull.js +2 -2
  224. package/dist/infer/presets/cookie-parser.d.ts +2 -2
  225. package/dist/infer/presets/cookie-parser.d.ts.map +1 -1
  226. package/dist/infer/presets/cron.d.ts +2 -2
  227. package/dist/infer/presets/cron.d.ts.map +1 -1
  228. package/dist/infer/presets/cron.js +1 -1
  229. package/dist/infer/presets/dotenv.d.ts +2 -2
  230. package/dist/infer/presets/dotenv.d.ts.map +1 -1
  231. package/dist/infer/presets/express-session.d.ts +2 -2
  232. package/dist/infer/presets/express-session.d.ts.map +1 -1
  233. package/dist/infer/presets/express-session.js +1 -1
  234. package/dist/infer/presets/google-cloud_storage.d.ts +2 -2
  235. package/dist/infer/presets/google-cloud_storage.d.ts.map +1 -1
  236. package/dist/infer/presets/google-maps.d.ts +2 -2
  237. package/dist/infer/presets/google-maps.d.ts.map +1 -1
  238. package/dist/infer/presets/ioredis.d.ts +2 -2
  239. package/dist/infer/presets/ioredis.d.ts.map +1 -1
  240. package/dist/infer/presets/ioredis.js +1 -1
  241. package/dist/infer/presets/jsonwebtoken.d.ts +2 -2
  242. package/dist/infer/presets/jsonwebtoken.d.ts.map +1 -1
  243. package/dist/infer/presets/jsonwebtoken.js +1 -1
  244. package/dist/infer/presets/mongoose.d.ts +2 -2
  245. package/dist/infer/presets/mongoose.d.ts.map +1 -1
  246. package/dist/infer/presets/mongoose.js +1 -1
  247. package/dist/infer/presets/multer.d.ts +2 -2
  248. package/dist/infer/presets/multer.d.ts.map +1 -1
  249. package/dist/infer/presets/mysql2.d.ts +2 -2
  250. package/dist/infer/presets/mysql2.d.ts.map +1 -1
  251. package/dist/infer/presets/mysql2.js +1 -1
  252. package/dist/infer/presets/newrelic.d.ts +2 -2
  253. package/dist/infer/presets/newrelic.d.ts.map +1 -1
  254. package/dist/infer/presets/node.d.ts +2 -2
  255. package/dist/infer/presets/node.d.ts.map +1 -1
  256. package/dist/infer/presets/node.js +5 -5
  257. package/dist/infer/presets/nodemailer.d.ts +2 -2
  258. package/dist/infer/presets/nodemailer.d.ts.map +1 -1
  259. package/dist/infer/presets/nodemailer.js +2 -2
  260. package/dist/infer/presets/passport-github2.d.ts +2 -2
  261. package/dist/infer/presets/passport-github2.d.ts.map +1 -1
  262. package/dist/infer/presets/passport-google-oauth20.d.ts +2 -2
  263. package/dist/infer/presets/passport-google-oauth20.d.ts.map +1 -1
  264. package/dist/infer/presets/passport-jwt.d.ts +2 -2
  265. package/dist/infer/presets/passport-jwt.d.ts.map +1 -1
  266. package/dist/infer/presets/passport.d.ts +2 -2
  267. package/dist/infer/presets/passport.d.ts.map +1 -1
  268. package/dist/infer/presets/pg.d.ts +2 -2
  269. package/dist/infer/presets/pg.d.ts.map +1 -1
  270. package/dist/infer/presets/pg.js +1 -1
  271. package/dist/infer/presets/pino.d.ts +2 -2
  272. package/dist/infer/presets/pino.d.ts.map +1 -1
  273. package/dist/infer/presets/prisma.d.ts +2 -2
  274. package/dist/infer/presets/prisma.d.ts.map +1 -1
  275. package/dist/infer/presets/prisma.js +2 -2
  276. package/dist/infer/presets/sentry.d.ts +2 -2
  277. package/dist/infer/presets/sentry.d.ts.map +1 -1
  278. package/dist/infer/presets/sentry.js +1 -1
  279. package/dist/infer/presets/stripe.d.ts +2 -2
  280. package/dist/infer/presets/stripe.d.ts.map +1 -1
  281. package/dist/infer/presets/typeorm.d.ts +2 -2
  282. package/dist/infer/presets/typeorm.d.ts.map +1 -1
  283. package/dist/infer/presets/typeorm.js +2 -2
  284. package/dist/infer/presets/vitest.d.ts +2 -2
  285. package/dist/infer/presets/vitest.d.ts.map +1 -1
  286. package/dist/infer/presets/vitest.js +1 -1
  287. package/dist/infer/presets/winston.d.ts +2 -2
  288. package/dist/infer/presets/winston.d.ts.map +1 -1
  289. package/dist/infer/presets.d.ts +5 -4
  290. package/dist/infer/presets.d.ts.map +1 -1
  291. package/dist/infer/presets.js +43 -16
  292. package/dist/infer/presets.types.d.ts +8 -2
  293. package/dist/infer/presets.types.d.ts.map +1 -1
  294. package/dist/infer/process.env/infer-collector.d.ts +7 -0
  295. package/dist/infer/process.env/infer-collector.d.ts.map +1 -0
  296. package/dist/infer/process.env/infer-collector.js +26 -0
  297. package/dist/infer/report.types.d.ts +57 -0
  298. package/dist/infer/report.types.d.ts.map +1 -0
  299. package/dist/infer/report.types.js +1 -0
  300. package/dist/infer/rules/basic.d.ts +9 -4
  301. package/dist/infer/rules/basic.d.ts.map +1 -1
  302. package/dist/infer/rules/basic.js +28 -14
  303. package/dist/infer/rules/boolean.d.ts +2 -2
  304. package/dist/infer/rules/boolean.d.ts.map +1 -1
  305. package/dist/infer/rules/boolean.js +5 -3
  306. package/dist/infer/rules/duration.d.ts +2 -2
  307. package/dist/infer/rules/duration.d.ts.map +1 -1
  308. package/dist/infer/rules/duration.js +18 -9
  309. package/dist/infer/rules/ip.d.ts +2 -2
  310. package/dist/infer/rules/ip.d.ts.map +1 -1
  311. package/dist/infer/rules/ip.js +5 -3
  312. package/dist/infer/rules/json.d.ts +2 -2
  313. package/dist/infer/rules/json.d.ts.map +1 -1
  314. package/dist/infer/rules/json.js +6 -5
  315. package/dist/infer/rules/key-value.d.ts +2 -2
  316. package/dist/infer/rules/key-value.d.ts.map +1 -1
  317. package/dist/infer/rules/key-value.js +7 -5
  318. package/dist/infer/rules/list.d.ts +2 -2
  319. package/dist/infer/rules/list.d.ts.map +1 -1
  320. package/dist/infer/rules/list.js +7 -5
  321. package/dist/infer/rules/port.d.ts +2 -2
  322. package/dist/infer/rules/port.d.ts.map +1 -1
  323. package/dist/infer/rules/port.js +5 -3
  324. package/dist/infer/rules/url.d.ts +2 -2
  325. package/dist/infer/rules/url.d.ts.map +1 -1
  326. package/dist/infer/rules/url.js +8 -6
  327. package/dist/infer/rules/version.d.ts +2 -2
  328. package/dist/infer/rules/version.d.ts.map +1 -1
  329. package/dist/infer/rules/version.js +5 -3
  330. package/dist/infer/rules.d.ts.map +1 -1
  331. package/dist/infer/rules.js +1 -1
  332. package/dist/infer/rules.types.d.ts +13 -4
  333. package/dist/infer/rules.types.d.ts.map +1 -1
  334. package/dist/infer/scripts/official-preset-registry.gen.d.ts.map +1 -1
  335. package/dist/infer/scripts/official-preset-registry.gen.js +2 -2
  336. package/dist/infer/secret-rules/secret.d.ts +3 -0
  337. package/dist/infer/secret-rules/secret.d.ts.map +1 -0
  338. package/dist/infer/secret-rules/secret.js +10 -0
  339. package/dist/infer/secret.d.ts +3 -0
  340. package/dist/infer/secret.d.ts.map +1 -0
  341. package/dist/infer/secret.js +10 -0
  342. package/dist/infer/secret.types.d.ts +6 -0
  343. package/dist/infer/secret.types.d.ts.map +1 -0
  344. package/dist/infer/secret.types.js +4 -0
  345. package/dist/llm-kit/context.json.d.ts +1 -1
  346. package/dist/llm-kit/context.json.d.ts.map +1 -1
  347. package/dist/llm-kit/context.json.js +1 -2
  348. package/dist/process/process-collector.d.ts +5 -0
  349. package/dist/process/process-collector.d.ts.map +1 -0
  350. package/dist/process/process-collector.js +34 -0
  351. package/dist/process/process-engine.d.ts +4 -0
  352. package/dist/process/process-engine.d.ts.map +1 -0
  353. package/dist/process/process-engine.js +45 -0
  354. package/dist/process/report.type.d.ts +27 -0
  355. package/dist/process/report.type.d.ts.map +1 -0
  356. package/dist/process/report.type.js +1 -0
  357. package/dist/process/rules/fallback.d.ts +3 -0
  358. package/dist/process/rules/fallback.d.ts.map +1 -0
  359. package/dist/process/rules/fallback.js +26 -0
  360. package/dist/process/rules/process-env-var.d.ts +3 -0
  361. package/dist/process/rules/process-env-var.d.ts.map +1 -0
  362. package/dist/process/rules/process-env-var.js +37 -0
  363. package/dist/process/rules/warn-unknown-var.d.ts +3 -0
  364. package/dist/process/rules/warn-unknown-var.d.ts.map +1 -0
  365. package/dist/process/rules/warn-unknown-var.js +40 -0
  366. package/dist/process/types.d.ts +28 -0
  367. package/dist/process/types.d.ts.map +1 -0
  368. package/dist/process/types.js +1 -0
  369. package/dist/sample/dummy-exporter.d.ts +7 -0
  370. package/dist/sample/dummy-exporter.d.ts.map +1 -0
  371. package/dist/sample/env.dnl.d.ts +29 -14
  372. package/dist/sample/env.dnl.d.ts.map +1 -1
  373. package/dist/sample/env.dnl.js +47 -19
  374. package/dist/sample/main.d.ts +1 -1
  375. package/dist/sample/main.d.ts.map +1 -1
  376. package/dist/sample/main.js +5 -17
  377. package/dist/sample/process-env.example.d.ts +13 -0
  378. package/dist/sample/process-env.example.d.ts.map +1 -0
  379. package/dist/sample/process-env.example.js +56 -0
  380. package/dist/sample/sample-exporter.d.ts +50 -0
  381. package/dist/sample/sample-exporter.d.ts.map +1 -0
  382. package/dist/sample/sample-exporter.js +79 -0
  383. package/dist/schemas/duration.d.ts +1 -0
  384. package/dist/schemas/duration.d.ts.map +1 -1
  385. package/dist/schemas/duration.js +1 -1
  386. package/dist/schemas/path.d.ts.map +1 -1
  387. package/dist/schemas/path.js +5 -6
  388. package/dist/schemas/urls.d.ts.map +1 -1
  389. package/dist/schemas/urls.js +1 -3
  390. package/dist/scripts/script-desc.d.ts.map +1 -1
  391. package/dist/scripts/script-desc.js +1 -3
  392. package/dist/utils/read-user-package-json.d.ts +6 -1
  393. package/dist/utils/read-user-package-json.d.ts.map +1 -1
  394. package/dist/utils/read-user-package-json.js +14 -3
  395. package/package.json +25 -7
package/README.md CHANGED
@@ -8,7 +8,9 @@
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
+
13
+ ### Why?
12
14
 
13
15
  ecause all of this happens all the time:
14
16
 
@@ -29,7 +31,7 @@ And because `.env` files are:
29
31
 
30
32
  ---
31
33
 
32
- ## What the library does
34
+ ### What the library does
33
35
 
34
36
  - ✅ validates environment variables at startup
35
37
  powered by Zod, enabling complex transformations (arrays, parsing, coercion…)
@@ -41,7 +43,7 @@ And because `.env` files are:
41
43
 
42
44
  ---
43
45
 
44
- ## What dotenv-never-lies is not
46
+ ### What dotenv-never-lies is not
45
47
 
46
48
  This package has a deliberately limited scope.
47
49
 
@@ -71,7 +73,7 @@ that prefer to **fail cleanly at startup** rather than **silently break in produ
71
73
 
72
74
  ---
73
75
 
74
- ## Installation
76
+ ### Installation
75
77
 
76
78
  ```bash
77
79
  npm install @romaintaillandier1978/dotenv-never-lies
@@ -79,7 +81,7 @@ npm install @romaintaillandier1978/dotenv-never-lies
79
81
  yarn add @romaintaillandier1978/dotenv-never-lies
80
82
  ```
81
83
 
82
- ## Dependencies and compatibility
84
+ ### Dependencies and compatibility
83
85
 
84
86
  **[`zod`](https://www.npmjs.com/package/zod)** — dotenv-never-lies exposes Zod schemas in its public API.
85
87
 
@@ -127,6 +129,12 @@ Supported in this order for all CLI commands:
127
129
 
128
130
  3. one of `env.dnl.ts`, `env.dnl.js`, `dnl.config.ts`, `dnl.config.js`
129
131
 
132
+ 4. as you wish, using the `--schema` option
133
+
134
+ ```bash
135
+ dnl infer --schema path/to/my-dnl.ts
136
+ ```
137
+
130
138
  ### define a schema
131
139
 
132
140
  ```typescript
@@ -157,11 +165,11 @@ export default define({
157
165
  });
158
166
  ```
159
167
 
160
- ## Secrets handling
168
+ ### Secrets handling
161
169
 
162
170
  Reminder: dotenv-never-lies is not a secrets manager.
163
171
 
164
- ### declaration in the DNL schema
172
+ **declaration in the DNL schema**
165
173
 
166
174
  A variable is considered secret if and only if it is explicitly marked in the schema with `secret: true`.
167
175
  (`secret: undefined` is equivalent to `secret: false`)
@@ -199,6 +207,8 @@ This separation ensures that validation, runtime usage and configuration export
199
207
 
200
208
  ## Runtime usage
201
209
 
210
+ ### assert: validate variables at runtime
211
+
202
212
  ```typescript
203
213
  import envDef from "./env.dnl";
204
214
 
@@ -226,10 +236,9 @@ Result:
226
236
  If a variable is missing or invalid → the process exits immediately.
227
237
  This is intentional.
228
238
 
229
- ## Avoid `process.env` in application code
239
+ ### Avoid `process.env` in application code
230
240
 
231
- Once the schema is loaded, environment variables
232
- must be accessed exclusively via the `ENV` object.
241
+ Once the schema is loaded, environment variables must be accessed exclusively via the `ENV` object.
233
242
 
234
243
  This guarantees:
235
244
 
@@ -237,17 +246,13 @@ This guarantees:
237
246
  - validated values
238
247
  - a single entry point for configuration
239
248
 
240
- To identify residual `process.env` usages in your codebase, a simple search tool is enough:
241
-
242
- ```bash
243
- grep -R "process\.env" src
244
- ```
249
+ To identify residual `process.env` usages in your codebase, use the `dnl annotate` [annotate command](docs/commands/annotate.md) for more details.
245
250
 
246
251
  Choosing to refactor (or not) those usages depends on context and is intentionally left to the developer.
247
252
 
248
253
  ## CLI
249
254
 
250
- 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.
251
256
 
252
257
  It is designed to be used:
253
258
 
@@ -267,17 +272,58 @@ It is designed to be used:
267
272
  | 3 | Environment validation failed |
268
273
  | 4 | Error during export |
269
274
 
270
- ### 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)
271
313
 
272
314
  Validates variables without injecting them into `process.env`.
273
315
 
274
316
  ```bash
275
- dnl assert --source .env --schema env.dnl.ts
317
+ dnl assert --source .env
276
318
  ```
277
319
 
278
320
  Without `--source`, `dnl assert` validates `process.env`.
279
321
  This is the recommended mode when variables are injected by the runtime or CI.
280
322
 
323
+ ```bash
324
+ dnl assert
325
+ ```
326
+
281
327
  → fails if:
282
328
 
283
329
  - a variable is missing
@@ -290,7 +336,7 @@ Initialize a documented `.env` from the schema.
290
336
  Do not read any environment variables
291
337
 
292
338
  ```bash
293
- dnl init --schema env.dnl.ts --out .env
339
+ dnl init --out .env
294
340
  ```
295
341
 
296
342
  Useful for:
@@ -299,18 +345,6 @@ Useful for:
299
345
  - sharing a template
300
346
  - avoiding obsolete `.env.example` files
301
347
 
302
- ### infer: discover a .envfile, and generate a schema from an existing .env
303
-
304
- Generate a DNL schema from an existing `.env` file.
305
-
306
- ```bash
307
- dnl infer --source .env
308
- ```
309
-
310
- Useful for migrating an existing project
311
-
312
- → [Read infer documentation](docs/commands/infer.md)
313
-
314
348
  ### explain: Display variables documentation
315
349
 
316
350
  Displays the list of known variables and their description.
@@ -334,73 +368,25 @@ The `export` command transforms variables validated by the schema
334
368
  into formats directly consumable by other tools (Docker, CI, Kubernetes, scripts…).
335
369
 
336
370
  The schema remains the source of truth.
337
- Values are validated before export.
338
-
339
- ```bash
340
- dnl export <format>
341
- ```
371
+ Values are validated before export, and validated AND raw values are passed to the exporter.
342
372
 
343
- By default, values are read from `process.env`.
344
- A `.env` file can be provided via `--source`.
345
-
346
- Examples:
347
- Export environment variables as JSON from a `.env` file
348
-
349
- ```bash
350
- dnl export json --source .env
351
- ```
352
-
353
- Clean a `.env` file (remove comments and extraneous lines)
373
+ Example:
354
374
 
355
375
  ```bash
356
- dnl export env --source .env --out .env.clean
357
- dnl export env --source .env --out .env --force
376
+ dnl export docker-args
358
377
  ```
359
378
 
360
- Export variables as `docker-args`
379
+ Example output:
361
380
 
362
381
  ```bash
363
- dnl export docker-args --source .env
382
+ -e NODE_ENV=test -e NODE_PORT=3000 -e FRONT_URL=https://example.com
364
383
  ```
365
384
 
366
- Result:
385
+ See DNL documentation for more formats and options :
386
+ → [Read export documentation](docs/commands/export.md)
367
387
 
368
- ```bash
369
- -e "NODE_ENV=production" -e "NODE_PORT=3000"
370
- ```
371
-
372
- Export for GitHub Actions (variables)
373
-
374
- ```bash
375
- dnl export github-env
376
- ```
377
-
378
- Result:
379
-
380
- ```bash
381
- printf '%s\n' "NODE_ENV=production" >> $GITHUB_ENV
382
- printf '%s\n' "NODE_PORT=3000" >> $GITHUB_ENV
383
- ```
384
-
385
- There are a few more formats and options (see CLI docs `dnl export --help`).
386
-
387
- ## export types : Exporting TypeScript types
388
-
389
- `dnl export types` generates a `.d.ts` file describing the **static contract** of your environment variables.
390
-
391
- This file is intentionally **conservative**.
392
-
393
- ### Transformed variables
394
-
395
- If a variable uses a Zod `transform`, the exported type always reflects the **input type**, not the runtime output.
396
-
397
- In that case:
398
-
399
- - a warning is emitted in the CLI
400
- - the generated type is annotated with `@dnl-transform`
401
- - the runtime value returned by `assert()` may differ
402
-
403
- 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)
404
390
 
405
391
  ## Real-life usage
406
392
 
@@ -416,6 +402,7 @@ Add `.dnl/` to your `.gitignore`.
416
402
  Using **dotenv-never-lies** via Git hooks is strongly recommended:
417
403
 
418
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)
419
406
  - **post-merge**: immediately detects schema changes impacting the local environment
420
407
 
421
408
  The goal is simple:
@@ -438,11 +425,13 @@ mkdir -p .githooks
438
425
  cat > .githooks/pre-commit <<'EOF'
439
426
  #!/bin/sh
440
427
  yarn dnl assert --source .env
428
+ yarn dnl annotate --check --warn-as-error
441
429
  EOF
442
430
 
443
431
  cat > .githooks/post-merge <<'EOF'
444
432
  #!/bin/sh
445
433
  yarn dnl assert --source .env || true
434
+ yarn dnl annotate --check --warn-as-error || true
446
435
  EOF
447
436
 
448
437
  chmod +x .githooks/pre-commit .githooks/post-merge
@@ -535,14 +524,6 @@ This validates the environment before startup, without changing runtime behavior
535
524
 
536
525
  > This is optional. It does not replace runtime validation.
537
526
 
538
- **Intellisens and JSdoc for env vars**
539
-
540
- After using `dnl export types` and importing the generated file, you get strong typing, auto-completion, IntelliSense and JSDoc for each environment variable.
541
-
542
- ![IntelliSense and JSDoc for environment variables](docs/images/env-intellisense.png)
543
-
544
- > IntelliSense and JSDoc generated from the DNL schema after `dnl export types`.
545
-
546
527
  ## Common issues / Troubleshooting
547
528
 
548
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"}