@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.
- package/README.md +77 -96
- package/dist/annotate/annotate-collector.d.ts +2 -0
- package/dist/annotate/annotate-collector.d.ts.map +1 -0
- package/dist/annotate/annotate-collector.js +48 -0
- package/dist/annotate/annotate-engine.d.ts +8 -0
- package/dist/annotate/annotate-engine.d.ts.map +1 -0
- package/dist/annotate/annotate-engine.js +52 -0
- package/dist/annotate/annotate-remove-engine.d.ts +2 -0
- package/dist/annotate/annotate-remove-engine.d.ts.map +1 -0
- package/dist/annotate/annotate-remove-engine.js +1 -0
- package/dist/annotate/helper.d.ts +26 -0
- package/dist/annotate/helper.d.ts.map +1 -0
- package/dist/annotate/helper.js +76 -0
- package/dist/annotate/report.type.d.ts +43 -0
- package/dist/annotate/report.type.d.ts.map +1 -0
- package/dist/annotate/report.type.js +7 -0
- package/dist/annotate/rules/add.d.ts +3 -0
- package/dist/annotate/rules/add.d.ts.map +1 -0
- package/dist/annotate/rules/add.js +67 -0
- package/dist/annotate/rules/annotate.d.ts +3 -0
- package/dist/annotate/rules/annotate.d.ts.map +1 -0
- package/dist/annotate/rules/annotate.js +30 -0
- package/dist/annotate/rules/check.d.ts +3 -0
- package/dist/annotate/rules/check.d.ts.map +1 -0
- package/dist/annotate/rules/check.js +56 -0
- package/dist/annotate/rules/fallback.d.ts +3 -0
- package/dist/annotate/rules/fallback.d.ts.map +1 -0
- package/dist/annotate/rules/fallback.js +36 -0
- package/dist/annotate/rules/ignore.d.ts +3 -0
- package/dist/annotate/rules/ignore.d.ts.map +1 -0
- package/dist/annotate/rules/ignore.js +40 -0
- package/dist/annotate/rules/process-env-var.d.ts +3 -0
- package/dist/annotate/rules/process-env-var.d.ts.map +1 -0
- package/dist/annotate/rules/process-env-var.js +36 -0
- package/dist/annotate/rules/recommandation.d.ts +3 -0
- package/dist/annotate/rules/recommandation.d.ts.map +1 -0
- package/dist/annotate/rules/recommandation.js +31 -0
- package/dist/annotate/rules/remove-annotation.d.ts +3 -0
- package/dist/annotate/rules/remove-annotation.d.ts.map +1 -0
- package/dist/annotate/rules/remove-annotation.js +48 -0
- package/dist/annotate/rules/remove.d.ts +3 -0
- package/dist/annotate/rules/remove.d.ts.map +1 -0
- package/dist/annotate/rules/remove.js +41 -0
- package/dist/annotate/rules/simple-annotation.d.ts +3 -0
- package/dist/annotate/rules/simple-annotation.d.ts.map +1 -0
- package/dist/annotate/rules/simple-annotation.js +53 -0
- package/dist/annotate/rules/warn-unknown-var.d.ts +3 -0
- package/dist/annotate/rules/warn-unknown-var.d.ts.map +1 -0
- package/dist/annotate/rules/warn-unknown-var.js +38 -0
- package/dist/annotate/types.d.ts +30 -0
- package/dist/annotate/types.d.ts.map +1 -0
- package/dist/annotate/types.js +1 -0
- package/dist/ast-tools/ast-helpers.d.ts +19 -0
- package/dist/ast-tools/ast-helpers.d.ts.map +1 -0
- package/dist/ast-tools/ast-helpers.js +94 -0
- package/dist/ast-tools/ast.types.d.ts +22 -0
- package/dist/ast-tools/ast.types.d.ts.map +1 -0
- package/dist/ast-tools/ast.types.js +1 -0
- package/dist/ast-tools/process-env-usage-collector.d.ts +10 -0
- package/dist/ast-tools/process-env-usage-collector.d.ts.map +1 -0
- package/dist/ast-tools/process-env-usage-collector.js +150 -0
- package/dist/cli/commands/annotate.d.ts +15 -0
- package/dist/cli/commands/annotate.d.ts.map +1 -0
- package/dist/cli/commands/annotate.js +88 -0
- package/dist/cli/commands/assert.d.ts.map +1 -1
- package/dist/cli/commands/assert.js +1 -0
- package/dist/cli/commands/explain.d.ts.map +1 -1
- package/dist/cli/commands/explain.js +2 -0
- package/dist/cli/commands/export.d.ts +5 -30
- package/dist/cli/commands/export.d.ts.map +1 -1
- package/dist/cli/commands/export.js +20 -326
- package/dist/cli/commands/infer.d.ts +2 -2
- package/dist/cli/commands/infer.d.ts.map +1 -1
- package/dist/cli/commands/infer.js +186 -48
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +2 -0
- package/dist/cli/commands/process-check.d.ts +7 -0
- package/dist/cli/commands/process-check.d.ts.map +1 -0
- package/dist/cli/commands/process-check.js +6 -0
- package/dist/cli/commands/process-fix.d.ts +9 -0
- package/dist/cli/commands/process-fix.d.ts.map +1 -0
- package/dist/cli/commands/process-fix.js +58 -0
- package/dist/cli/commands/types.d.ts +14 -0
- package/dist/cli/commands/types.d.ts.map +1 -0
- package/dist/cli/commands/types.js +56 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +224 -237
- package/dist/cli/utils/infer-rule-engine.d.ts +3 -2
- package/dist/cli/utils/infer-rule-engine.d.ts.map +1 -1
- package/dist/cli/utils/infer-rule-engine.js +23 -18
- package/dist/cli/utils/load-schema.d.ts.map +1 -1
- package/dist/cli/utils/load-schema.js +1 -0
- package/dist/cli/utils/printer.d.ts.map +1 -1
- package/dist/cli/utils/printer.js +9 -9
- package/dist/cli/utils/report.d.ts +15 -0
- package/dist/cli/utils/report.d.ts.map +1 -0
- package/dist/cli/utils/report.js +173 -0
- package/dist/cli/utils/resolve-schema.d.ts.map +1 -1
- package/dist/cli/utils/valid-identifier.d.ts +3 -0
- package/dist/cli/utils/valid-identifier.d.ts.map +1 -0
- package/dist/cli/utils/valid-identifier.js +9 -0
- package/dist/core.d.ts +6 -5
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +1 -1
- package/dist/dnl-config.d.ts.map +1 -1
- package/dist/dnl-config.js +4 -2
- package/dist/errors.d.ts +5 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +6 -0
- package/dist/export/export.types.d.ts +87 -0
- package/dist/export/export.types.d.ts.map +1 -0
- package/dist/export/export.types.js +8 -0
- package/dist/export/exporters/docker-args.exporter.d.ts +9 -0
- package/dist/export/exporters/docker-args.exporter.d.ts.map +1 -0
- package/dist/export/exporters/docker-args.exporter.js +33 -0
- package/dist/export/exporters/docker-env.exporter.d.ts +8 -0
- package/dist/export/exporters/docker-env.exporter.d.ts.map +1 -0
- package/dist/export/exporters/docker-env.exporter.js +19 -0
- package/dist/export/exporters/env.exporter.d.ts +8 -0
- package/dist/export/exporters/env.exporter.d.ts.map +1 -0
- package/dist/export/exporters/env.exporter.js +19 -0
- package/dist/export/exporters/github-env.exporter.d.ts +8 -0
- package/dist/export/exporters/github-env.exporter.d.ts.map +1 -0
- package/dist/export/exporters/github-env.exporter.js +15 -0
- package/dist/export/exporters/github-secret.exporter.d.ts +12 -0
- package/dist/export/exporters/github-secret.exporter.d.ts.map +1 -0
- package/dist/export/exporters/github-secret.exporter.js +38 -0
- package/dist/export/exporters/gitlab-env.exporter.d.ts +9 -0
- package/dist/export/exporters/gitlab-env.exporter.d.ts.map +1 -0
- package/dist/export/exporters/gitlab-env.exporter.js +25 -0
- package/dist/export/exporters/index.d.ts +12 -0
- package/dist/export/exporters/index.d.ts.map +1 -0
- package/dist/export/exporters/index.js +11 -0
- package/dist/export/exporters/js.exporter.d.ts +9 -0
- package/dist/export/exporters/js.exporter.d.ts.map +1 -0
- package/dist/export/exporters/js.exporter.js +24 -0
- package/dist/export/exporters/json.exporter.d.ts +12 -0
- package/dist/export/exporters/json.exporter.d.ts.map +1 -0
- package/dist/export/exporters/json.exporter.js +20 -0
- package/dist/export/exporters/k8s-configmap.exporter.d.ts +12 -0
- package/dist/export/exporters/k8s-configmap.exporter.d.ts.map +1 -0
- package/dist/export/exporters/k8s-configmap.exporter.js +37 -0
- package/dist/export/exporters/k8s-secret.exporter.d.ts +12 -0
- package/dist/export/exporters/k8s-secret.exporter.d.ts.map +1 -0
- package/dist/export/exporters/k8s-secret.exporter.js +35 -0
- package/dist/export/exporters/shared.d.ts +12 -0
- package/dist/export/exporters/shared.d.ts.map +1 -0
- package/dist/export/exporters/shared.js +35 -0
- package/dist/export/exporters/ts.exporter copy.d.ts +12 -0
- package/dist/export/exporters/ts.exporter copy.d.ts.map +1 -0
- package/dist/export/exporters/ts.exporter copy.js +25 -0
- package/dist/export/exporters/ts.exporter.d.ts +12 -0
- package/dist/export/exporters/ts.exporter.d.ts.map +1 -0
- package/dist/export/exporters/ts.exporter.js +25 -0
- package/dist/export/index.d.ts +3 -0
- package/dist/export/index.d.ts.map +1 -0
- package/dist/export/index.js +2 -0
- package/dist/export/registry.d.ts +17 -0
- package/dist/export/registry.d.ts.map +1 -0
- package/dist/export/registry.js +104 -0
- package/dist/export/shared.d.ts +31 -0
- package/dist/export/shared.d.ts.map +1 -0
- package/dist/export/shared.js +118 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/infer/__tests__/port-vs-version.test.js +1 -1
- package/dist/infer/__tests__/rules/basic.test.js +6 -6
- package/dist/infer/__tests__/rules/duration.test.js +2 -1
- package/dist/infer/__tests__/rules/json.test.js +1 -1
- package/dist/infer/__tests__/rules/url.test.js +2 -2
- package/dist/infer/__tests__/rules/version.test.js +1 -1
- package/dist/infer/cross-rules/secret-non-string.d.ts +1 -1
- package/dist/infer/cross-rules/secret-non-string.d.ts.map +1 -1
- package/dist/infer/cross-rules/secret-non-string.js +6 -3
- package/dist/infer/cross.d.ts +5 -0
- package/dist/infer/cross.d.ts.map +1 -0
- package/dist/infer/cross.js +16 -0
- package/dist/infer/cross.types.d.ts +30 -0
- package/dist/infer/cross.types.d.ts.map +1 -0
- package/dist/infer/cross.types.js +1 -0
- package/dist/infer/generated/basic.d.ts +1 -1
- package/dist/infer/generated/boolean.d.ts +1 -1
- package/dist/infer/generated/duration.d.ts +1 -1
- package/dist/infer/generated/ip.d.ts +1 -1
- package/dist/infer/generated/json.d.ts +1 -1
- package/dist/infer/generated/key-value.d.ts +1 -1
- package/dist/infer/generated/list.d.ts +1 -1
- package/dist/infer/generated/port.d.ts +1 -1
- package/dist/infer/generated/url.d.ts +1 -1
- package/dist/infer/generated/version.d.ts +1 -1
- package/dist/infer/helpers.d.ts +1 -2
- package/dist/infer/helpers.d.ts.map +1 -1
- package/dist/infer/helpers.js +0 -4
- package/dist/infer/heuristic.d.ts +4 -0
- package/dist/infer/heuristic.d.ts.map +1 -0
- package/dist/infer/heuristic.js +56 -0
- package/dist/infer/heuristic.types.d.ts +54 -0
- package/dist/infer/heuristic.types.d.ts.map +1 -0
- package/dist/infer/heuristic.types.js +1 -0
- package/dist/infer/heuristicRules.d.ts +6 -0
- package/dist/infer/heuristicRules.d.ts.map +1 -0
- package/dist/infer/heuristicRules.js +31 -0
- package/dist/infer/infer.types.d.ts +83 -0
- package/dist/infer/infer.types.d.ts.map +1 -0
- package/dist/infer/infer.types.js +17 -0
- package/dist/infer/official-preset-registry.d.ts +2 -2
- package/dist/infer/official-preset-registry.d.ts.map +1 -1
- package/dist/infer/presets/agenda.d.ts +2 -2
- package/dist/infer/presets/agenda.d.ts.map +1 -1
- package/dist/infer/presets/agenda.js +1 -1
- package/dist/infer/presets/amqplib.d.ts +2 -2
- package/dist/infer/presets/amqplib.d.ts.map +1 -1
- package/dist/infer/presets/amqplib.js +1 -1
- package/dist/infer/presets/aws-sdk.d.ts +2 -2
- package/dist/infer/presets/aws-sdk.d.ts.map +1 -1
- package/dist/infer/presets/aws-sdk_client-s3.d.ts +2 -2
- package/dist/infer/presets/aws-sdk_client-s3.d.ts.map +1 -1
- package/dist/infer/presets/bcrypt.d.ts +2 -2
- package/dist/infer/presets/bcrypt.d.ts.map +1 -1
- package/dist/infer/presets/bull.d.ts +2 -2
- package/dist/infer/presets/bull.d.ts.map +1 -1
- package/dist/infer/presets/bull.js +2 -2
- package/dist/infer/presets/cookie-parser.d.ts +2 -2
- package/dist/infer/presets/cookie-parser.d.ts.map +1 -1
- package/dist/infer/presets/cron.d.ts +2 -2
- package/dist/infer/presets/cron.d.ts.map +1 -1
- package/dist/infer/presets/cron.js +1 -1
- package/dist/infer/presets/dotenv.d.ts +2 -2
- package/dist/infer/presets/dotenv.d.ts.map +1 -1
- package/dist/infer/presets/express-session.d.ts +2 -2
- package/dist/infer/presets/express-session.d.ts.map +1 -1
- package/dist/infer/presets/express-session.js +1 -1
- package/dist/infer/presets/google-cloud_storage.d.ts +2 -2
- package/dist/infer/presets/google-cloud_storage.d.ts.map +1 -1
- package/dist/infer/presets/google-maps.d.ts +2 -2
- package/dist/infer/presets/google-maps.d.ts.map +1 -1
- package/dist/infer/presets/ioredis.d.ts +2 -2
- package/dist/infer/presets/ioredis.d.ts.map +1 -1
- package/dist/infer/presets/ioredis.js +1 -1
- package/dist/infer/presets/jsonwebtoken.d.ts +2 -2
- package/dist/infer/presets/jsonwebtoken.d.ts.map +1 -1
- package/dist/infer/presets/jsonwebtoken.js +1 -1
- package/dist/infer/presets/mongoose.d.ts +2 -2
- package/dist/infer/presets/mongoose.d.ts.map +1 -1
- package/dist/infer/presets/mongoose.js +1 -1
- package/dist/infer/presets/multer.d.ts +2 -2
- package/dist/infer/presets/multer.d.ts.map +1 -1
- package/dist/infer/presets/mysql2.d.ts +2 -2
- package/dist/infer/presets/mysql2.d.ts.map +1 -1
- package/dist/infer/presets/mysql2.js +1 -1
- package/dist/infer/presets/newrelic.d.ts +2 -2
- package/dist/infer/presets/newrelic.d.ts.map +1 -1
- package/dist/infer/presets/node.d.ts +2 -2
- package/dist/infer/presets/node.d.ts.map +1 -1
- package/dist/infer/presets/node.js +5 -5
- package/dist/infer/presets/nodemailer.d.ts +2 -2
- package/dist/infer/presets/nodemailer.d.ts.map +1 -1
- package/dist/infer/presets/nodemailer.js +2 -2
- package/dist/infer/presets/passport-github2.d.ts +2 -2
- package/dist/infer/presets/passport-github2.d.ts.map +1 -1
- package/dist/infer/presets/passport-google-oauth20.d.ts +2 -2
- package/dist/infer/presets/passport-google-oauth20.d.ts.map +1 -1
- package/dist/infer/presets/passport-jwt.d.ts +2 -2
- package/dist/infer/presets/passport-jwt.d.ts.map +1 -1
- package/dist/infer/presets/passport.d.ts +2 -2
- package/dist/infer/presets/passport.d.ts.map +1 -1
- package/dist/infer/presets/pg.d.ts +2 -2
- package/dist/infer/presets/pg.d.ts.map +1 -1
- package/dist/infer/presets/pg.js +1 -1
- package/dist/infer/presets/pino.d.ts +2 -2
- package/dist/infer/presets/pino.d.ts.map +1 -1
- package/dist/infer/presets/prisma.d.ts +2 -2
- package/dist/infer/presets/prisma.d.ts.map +1 -1
- package/dist/infer/presets/prisma.js +2 -2
- package/dist/infer/presets/sentry.d.ts +2 -2
- package/dist/infer/presets/sentry.d.ts.map +1 -1
- package/dist/infer/presets/sentry.js +1 -1
- package/dist/infer/presets/stripe.d.ts +2 -2
- package/dist/infer/presets/stripe.d.ts.map +1 -1
- package/dist/infer/presets/typeorm.d.ts +2 -2
- package/dist/infer/presets/typeorm.d.ts.map +1 -1
- package/dist/infer/presets/typeorm.js +2 -2
- package/dist/infer/presets/vitest.d.ts +2 -2
- package/dist/infer/presets/vitest.d.ts.map +1 -1
- package/dist/infer/presets/vitest.js +1 -1
- package/dist/infer/presets/winston.d.ts +2 -2
- package/dist/infer/presets/winston.d.ts.map +1 -1
- package/dist/infer/presets.d.ts +5 -4
- package/dist/infer/presets.d.ts.map +1 -1
- package/dist/infer/presets.js +43 -16
- package/dist/infer/presets.types.d.ts +8 -2
- package/dist/infer/presets.types.d.ts.map +1 -1
- package/dist/infer/process.env/infer-collector.d.ts +7 -0
- package/dist/infer/process.env/infer-collector.d.ts.map +1 -0
- package/dist/infer/process.env/infer-collector.js +26 -0
- package/dist/infer/report.types.d.ts +57 -0
- package/dist/infer/report.types.d.ts.map +1 -0
- package/dist/infer/report.types.js +1 -0
- package/dist/infer/rules/basic.d.ts +9 -4
- package/dist/infer/rules/basic.d.ts.map +1 -1
- package/dist/infer/rules/basic.js +28 -14
- package/dist/infer/rules/boolean.d.ts +2 -2
- package/dist/infer/rules/boolean.d.ts.map +1 -1
- package/dist/infer/rules/boolean.js +5 -3
- package/dist/infer/rules/duration.d.ts +2 -2
- package/dist/infer/rules/duration.d.ts.map +1 -1
- package/dist/infer/rules/duration.js +18 -9
- package/dist/infer/rules/ip.d.ts +2 -2
- package/dist/infer/rules/ip.d.ts.map +1 -1
- package/dist/infer/rules/ip.js +5 -3
- package/dist/infer/rules/json.d.ts +2 -2
- package/dist/infer/rules/json.d.ts.map +1 -1
- package/dist/infer/rules/json.js +6 -5
- package/dist/infer/rules/key-value.d.ts +2 -2
- package/dist/infer/rules/key-value.d.ts.map +1 -1
- package/dist/infer/rules/key-value.js +7 -5
- package/dist/infer/rules/list.d.ts +2 -2
- package/dist/infer/rules/list.d.ts.map +1 -1
- package/dist/infer/rules/list.js +7 -5
- package/dist/infer/rules/port.d.ts +2 -2
- package/dist/infer/rules/port.d.ts.map +1 -1
- package/dist/infer/rules/port.js +5 -3
- package/dist/infer/rules/url.d.ts +2 -2
- package/dist/infer/rules/url.d.ts.map +1 -1
- package/dist/infer/rules/url.js +8 -6
- package/dist/infer/rules/version.d.ts +2 -2
- package/dist/infer/rules/version.d.ts.map +1 -1
- package/dist/infer/rules/version.js +5 -3
- package/dist/infer/rules.d.ts.map +1 -1
- package/dist/infer/rules.js +1 -1
- package/dist/infer/rules.types.d.ts +13 -4
- package/dist/infer/rules.types.d.ts.map +1 -1
- package/dist/infer/scripts/official-preset-registry.gen.d.ts.map +1 -1
- package/dist/infer/scripts/official-preset-registry.gen.js +2 -2
- package/dist/infer/secret-rules/secret.d.ts +3 -0
- package/dist/infer/secret-rules/secret.d.ts.map +1 -0
- package/dist/infer/secret-rules/secret.js +10 -0
- package/dist/infer/secret.d.ts +3 -0
- package/dist/infer/secret.d.ts.map +1 -0
- package/dist/infer/secret.js +10 -0
- package/dist/infer/secret.types.d.ts +6 -0
- package/dist/infer/secret.types.d.ts.map +1 -0
- package/dist/infer/secret.types.js +4 -0
- package/dist/llm-kit/context.json.d.ts +1 -1
- package/dist/llm-kit/context.json.d.ts.map +1 -1
- package/dist/llm-kit/context.json.js +1 -2
- package/dist/process/process-collector.d.ts +5 -0
- package/dist/process/process-collector.d.ts.map +1 -0
- package/dist/process/process-collector.js +34 -0
- package/dist/process/process-engine.d.ts +4 -0
- package/dist/process/process-engine.d.ts.map +1 -0
- package/dist/process/process-engine.js +45 -0
- package/dist/process/report.type.d.ts +27 -0
- package/dist/process/report.type.d.ts.map +1 -0
- package/dist/process/report.type.js +1 -0
- package/dist/process/rules/fallback.d.ts +3 -0
- package/dist/process/rules/fallback.d.ts.map +1 -0
- package/dist/process/rules/fallback.js +26 -0
- package/dist/process/rules/process-env-var.d.ts +3 -0
- package/dist/process/rules/process-env-var.d.ts.map +1 -0
- package/dist/process/rules/process-env-var.js +37 -0
- package/dist/process/rules/warn-unknown-var.d.ts +3 -0
- package/dist/process/rules/warn-unknown-var.d.ts.map +1 -0
- package/dist/process/rules/warn-unknown-var.js +40 -0
- package/dist/process/types.d.ts +28 -0
- package/dist/process/types.d.ts.map +1 -0
- package/dist/process/types.js +1 -0
- package/dist/sample/dummy-exporter.d.ts +7 -0
- package/dist/sample/dummy-exporter.d.ts.map +1 -0
- package/dist/sample/env.dnl.d.ts +29 -14
- package/dist/sample/env.dnl.d.ts.map +1 -1
- package/dist/sample/env.dnl.js +47 -19
- package/dist/sample/main.d.ts +1 -1
- package/dist/sample/main.d.ts.map +1 -1
- package/dist/sample/main.js +5 -17
- package/dist/sample/process-env.example.d.ts +13 -0
- package/dist/sample/process-env.example.d.ts.map +1 -0
- package/dist/sample/process-env.example.js +56 -0
- package/dist/sample/sample-exporter.d.ts +50 -0
- package/dist/sample/sample-exporter.d.ts.map +1 -0
- package/dist/sample/sample-exporter.js +79 -0
- package/dist/schemas/duration.d.ts +1 -0
- package/dist/schemas/duration.d.ts.map +1 -1
- package/dist/schemas/duration.js +1 -1
- package/dist/schemas/path.d.ts.map +1 -1
- package/dist/schemas/path.js +5 -6
- package/dist/schemas/urls.d.ts.map +1 -1
- package/dist/schemas/urls.js +1 -3
- package/dist/scripts/script-desc.d.ts.map +1 -1
- package/dist/scripts/script-desc.js +1 -3
- package/dist/utils/read-user-package-json.d.ts +6 -1
- package/dist/utils/read-user-package-json.d.ts.map +1 -1
- package/dist/utils/read-user-package-json.js +14 -3
- 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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
168
|
+
### Secrets handling
|
|
161
169
|
|
|
162
170
|
Reminder: dotenv-never-lies is not a secrets manager.
|
|
163
171
|
|
|
164
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
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
|
-
###
|
|
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
|
|
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 --
|
|
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
|
-
|
|
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
|
|
357
|
-
dnl export env --source .env --out .env --force
|
|
376
|
+
dnl export docker-args
|
|
358
377
|
```
|
|
359
378
|
|
|
360
|
-
|
|
379
|
+
Example output:
|
|
361
380
|
|
|
362
381
|
```bash
|
|
363
|
-
|
|
382
|
+
-e NODE_ENV=test -e NODE_PORT=3000 -e FRONT_URL=https://example.com
|
|
364
383
|
```
|
|
365
384
|
|
|
366
|
-
|
|
385
|
+
See DNL documentation for more formats and options :
|
|
386
|
+
→ [Read export documentation](docs/commands/export.md)
|
|
367
387
|
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-

|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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"}
|