@romaintaillandier1978/dotenv-never-lies 1.3.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -101
- 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 +5 -1
- package/dist/cli/commands/assert.d.ts.map +1 -1
- package/dist/cli/commands/assert.js +6 -2
- 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 +6 -30
- package/dist/cli/commands/export.d.ts.map +1 -1
- package/dist/cli/commands/export.js +20 -304
- package/dist/cli/commands/infer.d.ts +6 -3
- package/dist/cli/commands/infer.d.ts.map +1 -1
- package/dist/cli/commands/infer.js +215 -39
- 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 +2 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +232 -220
- package/dist/cli/utils/infer-rule-engine.d.ts +5 -0
- package/dist/cli/utils/infer-rule-engine.d.ts.map +1 -0
- package/dist/cli/utils/infer-rule-engine.js +35 -0
- 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/resolve-schema.js +17 -16
- 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 +12 -6
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +29 -1
- package/dist/dnl-config.d.ts +10 -0
- package/dist/dnl-config.d.ts.map +1 -0
- package/dist/dnl-config.js +6 -0
- 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/key-value.test.d.ts +2 -0
- package/dist/infer/__tests__/rules/key-value.test.d.ts.map +1 -0
- package/dist/infer/__tests__/rules/key-value.test.js +56 -0
- package/dist/infer/__tests__/rules/list.test.js +12 -45
- 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 +3 -0
- package/dist/infer/cross-rules/secret-non-string.d.ts.map +1 -0
- package/dist/infer/cross-rules/secret-non-string.js +8 -0
- 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 +7 -7
- package/dist/infer/generated/basic.d.ts.map +1 -1
- package/dist/infer/generated/basic.js +12 -6
- package/dist/infer/generated/boolean.d.ts +2 -2
- package/dist/infer/generated/boolean.d.ts.map +1 -1
- package/dist/infer/generated/boolean.js +3 -2
- package/dist/infer/generated/duration.d.ts +2 -2
- package/dist/infer/generated/duration.d.ts.map +1 -1
- package/dist/infer/generated/duration.js +1 -0
- package/dist/infer/generated/ip.d.ts +2 -2
- package/dist/infer/generated/ip.d.ts.map +1 -1
- package/dist/infer/generated/ip.js +1 -0
- package/dist/infer/generated/json.d.ts +3 -3
- package/dist/infer/generated/json.d.ts.map +1 -1
- package/dist/infer/generated/json.js +1 -0
- package/dist/infer/generated/key-value.d.ts +4 -0
- package/dist/infer/generated/key-value.d.ts.map +1 -0
- package/dist/infer/generated/key-value.js +11 -0
- package/dist/infer/generated/list.d.ts +5 -7
- package/dist/infer/generated/list.d.ts.map +1 -1
- package/dist/infer/generated/list.js +13 -21
- package/dist/infer/generated/port.d.ts +3 -3
- package/dist/infer/generated/port.d.ts.map +1 -1
- package/dist/infer/generated/port.js +1 -0
- package/dist/infer/generated/url.d.ts +13 -13
- package/dist/infer/generated/url.d.ts.map +1 -1
- package/dist/infer/generated/url.js +6 -0
- package/dist/infer/generated/version.d.ts +3 -3
- package/dist/infer/generated/version.d.ts.map +1 -1
- package/dist/infer/generated/version.js +1 -0
- package/dist/infer/helpers.d.ts +1 -3
- package/dist/infer/helpers.d.ts.map +1 -1
- package/dist/infer/helpers.js +5 -20
- 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/index.d.ts +2 -2
- package/dist/infer/index.d.ts.map +1 -1
- package/dist/infer/index.js +7 -11
- 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 +3 -0
- package/dist/infer/official-preset-registry.d.ts.map +1 -0
- package/dist/infer/official-preset-registry.js +67 -0
- package/dist/infer/presets/agenda.d.ts +3 -0
- package/dist/infer/presets/agenda.d.ts.map +1 -0
- package/dist/infer/presets/agenda.js +15 -0
- package/dist/infer/presets/amqplib.d.ts +3 -0
- package/dist/infer/presets/amqplib.d.ts.map +1 -0
- package/dist/infer/presets/amqplib.js +15 -0
- package/dist/infer/presets/aws-sdk.d.ts +3 -0
- package/dist/infer/presets/aws-sdk.d.ts.map +1 -0
- package/dist/infer/presets/aws-sdk.js +33 -0
- package/dist/infer/presets/aws-sdk_client-s3.d.ts +3 -0
- package/dist/infer/presets/aws-sdk_client-s3.d.ts.map +1 -0
- package/dist/infer/presets/aws-sdk_client-s3.js +15 -0
- package/dist/infer/presets/bcrypt.d.ts +3 -0
- package/dist/infer/presets/bcrypt.d.ts.map +1 -0
- package/dist/infer/presets/bcrypt.js +15 -0
- package/dist/infer/presets/bull.d.ts +3 -0
- package/dist/infer/presets/bull.d.ts.map +1 -0
- package/dist/infer/presets/bull.js +116 -0
- package/dist/infer/presets/cookie-parser.d.ts +3 -0
- package/dist/infer/presets/cookie-parser.d.ts.map +1 -0
- package/dist/infer/presets/cookie-parser.js +15 -0
- package/dist/infer/presets/cron.d.ts +3 -0
- package/dist/infer/presets/cron.d.ts.map +1 -0
- package/dist/infer/presets/cron.js +22 -0
- package/dist/infer/presets/dotenv.d.ts +3 -0
- package/dist/infer/presets/dotenv.d.ts.map +1 -0
- package/dist/infer/presets/dotenv.js +15 -0
- package/dist/infer/presets/express-session.d.ts +3 -0
- package/dist/infer/presets/express-session.d.ts.map +1 -0
- package/dist/infer/presets/express-session.js +40 -0
- package/dist/infer/presets/google-cloud_storage.d.ts +3 -0
- package/dist/infer/presets/google-cloud_storage.d.ts.map +1 -0
- package/dist/infer/presets/google-cloud_storage.js +15 -0
- package/dist/infer/presets/google-maps.d.ts +3 -0
- package/dist/infer/presets/google-maps.d.ts.map +1 -0
- package/dist/infer/presets/google-maps.js +15 -0
- package/dist/infer/presets/ioredis.d.ts +3 -0
- package/dist/infer/presets/ioredis.d.ts.map +1 -0
- package/dist/infer/presets/ioredis.js +15 -0
- package/dist/infer/presets/jsonwebtoken.d.ts +3 -0
- package/dist/infer/presets/jsonwebtoken.d.ts.map +1 -0
- package/dist/infer/presets/jsonwebtoken.js +40 -0
- package/dist/infer/presets/mongoose.d.ts +3 -0
- package/dist/infer/presets/mongoose.d.ts.map +1 -0
- package/dist/infer/presets/mongoose.js +15 -0
- package/dist/infer/presets/multer.d.ts +3 -0
- package/dist/infer/presets/multer.d.ts.map +1 -0
- package/dist/infer/presets/multer.js +15 -0
- package/dist/infer/presets/mysql2.d.ts +3 -0
- package/dist/infer/presets/mysql2.d.ts.map +1 -0
- package/dist/infer/presets/mysql2.js +15 -0
- package/dist/infer/presets/newrelic.d.ts +3 -0
- package/dist/infer/presets/newrelic.d.ts.map +1 -0
- package/dist/infer/presets/newrelic.js +15 -0
- package/dist/infer/presets/node.d.ts +3 -0
- package/dist/infer/presets/node.d.ts.map +1 -0
- package/dist/infer/presets/node.js +47 -0
- package/dist/infer/presets/nodemailer.d.ts +3 -0
- package/dist/infer/presets/nodemailer.d.ts.map +1 -0
- package/dist/infer/presets/nodemailer.js +50 -0
- package/dist/infer/presets/passport-github2.d.ts +3 -0
- package/dist/infer/presets/passport-github2.d.ts.map +1 -0
- package/dist/infer/presets/passport-github2.js +24 -0
- package/dist/infer/presets/passport-google-oauth20.d.ts +3 -0
- package/dist/infer/presets/passport-google-oauth20.d.ts.map +1 -0
- package/dist/infer/presets/passport-google-oauth20.js +24 -0
- package/dist/infer/presets/passport-jwt.d.ts +3 -0
- package/dist/infer/presets/passport-jwt.d.ts.map +1 -0
- package/dist/infer/presets/passport-jwt.js +15 -0
- package/dist/infer/presets/passport.d.ts +3 -0
- package/dist/infer/presets/passport.d.ts.map +1 -0
- package/dist/infer/presets/passport.js +15 -0
- package/dist/infer/presets/pg.d.ts +3 -0
- package/dist/infer/presets/pg.d.ts.map +1 -0
- package/dist/infer/presets/pg.js +15 -0
- package/dist/infer/presets/pino.d.ts +3 -0
- package/dist/infer/presets/pino.d.ts.map +1 -0
- package/dist/infer/presets/pino.js +15 -0
- package/dist/infer/presets/prisma.d.ts +3 -0
- package/dist/infer/presets/prisma.d.ts.map +1 -0
- package/dist/infer/presets/prisma.js +24 -0
- package/dist/infer/presets/sentry.d.ts +3 -0
- package/dist/infer/presets/sentry.d.ts.map +1 -0
- package/dist/infer/presets/sentry.js +15 -0
- package/dist/infer/presets/something.d.ts +4 -0
- package/dist/infer/presets/something.d.ts.map +1 -0
- package/dist/infer/presets/something.js +29 -0
- package/dist/infer/presets/stripe.d.ts +3 -0
- package/dist/infer/presets/stripe.d.ts.map +1 -0
- package/dist/infer/presets/stripe.js +33 -0
- package/dist/infer/presets/typeorm.d.ts +3 -0
- package/dist/infer/presets/typeorm.d.ts.map +1 -0
- package/dist/infer/presets/typeorm.js +57 -0
- package/dist/infer/presets/vitest.d.ts +3 -0
- package/dist/infer/presets/vitest.d.ts.map +1 -0
- package/dist/infer/presets/vitest.js +13 -0
- package/dist/infer/presets/winston.d.ts +3 -0
- package/dist/infer/presets/winston.d.ts.map +1 -0
- package/dist/infer/presets/winston.js +15 -0
- package/dist/infer/presets.d.ts +7 -0
- package/dist/infer/presets.d.ts.map +1 -0
- package/dist/infer/presets.js +119 -0
- package/dist/infer/presets.types.d.ts +16 -0
- package/dist/infer/presets.types.d.ts.map +1 -0
- package/dist/infer/presets.types.js +1 -0
- 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 +31 -17
- 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 +7 -6
- package/dist/infer/rules/key-value.d.ts +3 -0
- package/dist/infer/rules/key-value.d.ts.map +1 -0
- package/dist/infer/rules/key-value.js +56 -0
- package/dist/infer/rules/list.d.ts +2 -4
- package/dist/infer/rules/list.d.ts.map +1 -1
- package/dist/infer/rules/list.js +56 -165
- 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 +6 -4
- 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 +22 -61
- 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 +5 -0
- package/dist/infer/rules.d.ts.map +1 -0
- package/dist/infer/rules.js +31 -0
- package/dist/infer/rules.types.d.ts +153 -0
- package/dist/infer/rules.types.d.ts.map +1 -0
- package/dist/infer/rules.types.js +17 -0
- package/dist/infer/scripts/official-preset-registry.gen.d.ts +13 -0
- package/dist/infer/scripts/official-preset-registry.gen.d.ts.map +1 -0
- package/dist/infer/scripts/official-preset-registry.gen.js +154 -0
- 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/infer/types.d.ts +60 -7
- package/dist/infer/types.d.ts.map +1 -1
- package/dist/infer/types.js +16 -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 -386
- package/dist/sample/env.dnl.d.ts.map +1 -1
- package/dist/sample/env.dnl.js +44 -393
- package/dist/sample/main.d.ts +2 -0
- package/dist/sample/main.d.ts.map +1 -0
- package/dist/sample/main.js +5 -0
- 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/boolean.d.ts +1 -1
- package/dist/schemas/boolean.d.ts.map +1 -1
- package/dist/schemas/boolean.js +1 -1
- package/dist/schemas/common.d.ts +39 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +1 -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/key-value.d.ts +10 -0
- package/dist/schemas/key-value.d.ts.map +1 -0
- package/dist/schemas/key-value.js +33 -0
- package/dist/schemas/list.d.ts +4 -46
- package/dist/schemas/list.d.ts.map +1 -1
- package/dist/schemas/list.js +1 -36
- package/dist/schemas/path.d.ts +2 -2
- package/dist/schemas/path.d.ts.map +1 -1
- package/dist/schemas/path.js +7 -8
- package/dist/schemas/urls.d.ts.map +1 -1
- package/dist/schemas/urls.js +8 -1
- package/dist/scripts/script-desc.d.ts +6 -0
- package/dist/scripts/script-desc.d.ts.map +1 -0
- package/dist/scripts/script-desc.js +24 -0
- package/dist/utils/read-user-package-json.d.ts +10 -0
- package/dist/utils/read-user-package-json.d.ts.map +1 -0
- package/dist/utils/read-user-package-json.js +37 -0
- package/package.json +47 -6
package/README.md
CHANGED
|
@@ -8,14 +8,17 @@
|
|
|
8
8
|
**dotenv-never-lies** validates, types, and documents your environment variables from a TypeScript / Zod schema.
|
|
9
9
|
It fails fast, loud, and before production.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Introduction#
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Why?
|
|
14
|
+
|
|
15
|
+
ecause all of this happens all the time:
|
|
14
16
|
|
|
15
17
|
- ❌ a missing env variable → runtime crash
|
|
16
18
|
- ❌ a malformed URL → subtle production bug
|
|
17
19
|
- ❌ CI was not updated after a new variable → confusing red deployment
|
|
18
20
|
- ❌ an optimistic `process.env.FOO!` → lying to yourself
|
|
21
|
+
- ❌ dotenv silently overrides duplicate keys
|
|
19
22
|
|
|
20
23
|
And because `.env` files are:
|
|
21
24
|
|
|
@@ -28,18 +31,19 @@ And because `.env` files are:
|
|
|
28
31
|
|
|
29
32
|
---
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
### What the library does
|
|
32
35
|
|
|
33
|
-
- ✅ validates environment variables at startup
|
|
34
|
-
powered by
|
|
35
|
-
- ✅
|
|
36
|
+
- ✅ validates environment variables at startup
|
|
37
|
+
powered by Zod, enabling complex transformations (arrays, parsing, coercion…)
|
|
38
|
+
- ✅ prevents duplicate environment variables
|
|
39
|
+
- ✅ infers a first real-world DNL schema from an existing `.env`
|
|
36
40
|
- ✅ provides reliable TypeScript typings
|
|
37
41
|
- ✅ documents each variable
|
|
38
|
-
- ✅ exposes a CLI for CI and humans (dnl export)
|
|
42
|
+
- ✅ exposes a CLI for CI and humans (`dnl export`)
|
|
39
43
|
|
|
40
44
|
---
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
### What dotenv-never-lies is not
|
|
43
47
|
|
|
44
48
|
This package has a deliberately limited scope.
|
|
45
49
|
|
|
@@ -69,7 +73,7 @@ that prefer to **fail cleanly at startup** rather than **silently break in produ
|
|
|
69
73
|
|
|
70
74
|
---
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
### Installation
|
|
73
77
|
|
|
74
78
|
```bash
|
|
75
79
|
npm install @romaintaillandier1978/dotenv-never-lies
|
|
@@ -77,7 +81,7 @@ npm install @romaintaillandier1978/dotenv-never-lies
|
|
|
77
81
|
yarn add @romaintaillandier1978/dotenv-never-lies
|
|
78
82
|
```
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
### Dependencies and compatibility
|
|
81
85
|
|
|
82
86
|
**[`zod`](https://www.npmjs.com/package/zod)** — dotenv-never-lies exposes Zod schemas in its public API.
|
|
83
87
|
|
|
@@ -125,6 +129,12 @@ Supported in this order for all CLI commands:
|
|
|
125
129
|
|
|
126
130
|
3. one of `env.dnl.ts`, `env.dnl.js`, `dnl.config.ts`, `dnl.config.js`
|
|
127
131
|
|
|
132
|
+
4. as you wish, using the `--schema` option
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
dnl infer --schema path/to/my-dnl.ts
|
|
136
|
+
```
|
|
137
|
+
|
|
128
138
|
### define a schema
|
|
129
139
|
|
|
130
140
|
```typescript
|
|
@@ -155,11 +165,11 @@ export default define({
|
|
|
155
165
|
});
|
|
156
166
|
```
|
|
157
167
|
|
|
158
|
-
|
|
168
|
+
### Secrets handling
|
|
159
169
|
|
|
160
170
|
Reminder: dotenv-never-lies is not a secrets manager.
|
|
161
171
|
|
|
162
|
-
|
|
172
|
+
**declaration in the DNL schema**
|
|
163
173
|
|
|
164
174
|
A variable is considered secret if and only if it is explicitly marked in the schema with `secret: true`.
|
|
165
175
|
(`secret: undefined` is equivalent to `secret: false`)
|
|
@@ -197,6 +207,8 @@ This separation ensures that validation, runtime usage and configuration export
|
|
|
197
207
|
|
|
198
208
|
## Runtime usage
|
|
199
209
|
|
|
210
|
+
### assert: validate variables at runtime
|
|
211
|
+
|
|
200
212
|
```typescript
|
|
201
213
|
import envDef from "./env.dnl";
|
|
202
214
|
|
|
@@ -224,10 +236,9 @@ Result:
|
|
|
224
236
|
If a variable is missing or invalid → the process exits immediately.
|
|
225
237
|
This is intentional.
|
|
226
238
|
|
|
227
|
-
|
|
239
|
+
### Avoid `process.env` in application code
|
|
228
240
|
|
|
229
|
-
Once the schema is loaded, environment variables
|
|
230
|
-
must be accessed exclusively via the `ENV` object.
|
|
241
|
+
Once the schema is loaded, environment variables must be accessed exclusively via the `ENV` object.
|
|
231
242
|
|
|
232
243
|
This guarantees:
|
|
233
244
|
|
|
@@ -235,17 +246,13 @@ This guarantees:
|
|
|
235
246
|
- validated values
|
|
236
247
|
- a single entry point for configuration
|
|
237
248
|
|
|
238
|
-
To identify residual `process.env` usages in your codebase,
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
grep -R "process\.env" src
|
|
242
|
-
```
|
|
249
|
+
To identify residual `process.env` usages in your codebase, use the `dnl annotate` [annotate command](docs/commands/annotate.md) for more details.
|
|
243
250
|
|
|
244
251
|
Choosing to refactor (or not) those usages depends on context and is intentionally left to the developer.
|
|
245
252
|
|
|
246
253
|
## CLI
|
|
247
254
|
|
|
248
|
-
The CLI lets you
|
|
255
|
+
The CLI lets you infer, types, assert, export, and explain environment variables to/from a `dotenv-never-lies` schema.
|
|
249
256
|
|
|
250
257
|
It is designed to be used:
|
|
251
258
|
|
|
@@ -265,17 +272,58 @@ It is designed to be used:
|
|
|
265
272
|
| 3 | Environment validation failed |
|
|
266
273
|
| 4 | Error during export |
|
|
267
274
|
|
|
268
|
-
###
|
|
275
|
+
### infer: discover a .envfile, and generate a schema from an existing .env
|
|
276
|
+
|
|
277
|
+
Generate a DNL schema from an existing `.env` file.
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
dnl infer --source .env
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Useful for migrating an existing project
|
|
284
|
+
|
|
285
|
+
→ [Read infer documentation](docs/commands/infer.md)
|
|
286
|
+
|
|
287
|
+
### types: generate a TypeScript declaration file from an existing DNL schema
|
|
288
|
+
|
|
289
|
+
Generates a `./src/types/env.dnl.d.ts` file from the `env.dnl.ts` file.
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
dnl types
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Useful for getting IntelliSense _after_ finalizing your DNL schema completion.
|
|
296
|
+
|
|
297
|
+
→ [Read infer documentation](docs/commands/types.md)
|
|
298
|
+
|
|
299
|
+
### annotate: Identify and manage `process.env` usages
|
|
300
|
+
|
|
301
|
+
Scans the codebase and adds contextual annotations to help migrate from `process.env` to DNL-validated variables.
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
dnl annotate
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
- Use locally to discover and progressively replace legacy `process.env` usages.
|
|
308
|
+
- Use `dnl annotate --check` in CI or Git hooks (pre-commit, post-merge) to prevent introducing new unreviewed `process.env` accesses.
|
|
309
|
+
|
|
310
|
+
→ [Read annotate documentation](docs/commands/annotate.md)
|
|
311
|
+
|
|
312
|
+
### assert: Validate environement variables (runtime, CI-friendly)
|
|
269
313
|
|
|
270
314
|
Validates variables without injecting them into `process.env`.
|
|
271
315
|
|
|
272
316
|
```bash
|
|
273
|
-
dnl assert --source .env
|
|
317
|
+
dnl assert --source .env
|
|
274
318
|
```
|
|
275
319
|
|
|
276
320
|
Without `--source`, `dnl assert` validates `process.env`.
|
|
277
321
|
This is the recommended mode when variables are injected by the runtime or CI.
|
|
278
322
|
|
|
323
|
+
```bash
|
|
324
|
+
dnl assert
|
|
325
|
+
```
|
|
326
|
+
|
|
279
327
|
→ fails if:
|
|
280
328
|
|
|
281
329
|
- a variable is missing
|
|
@@ -288,7 +336,7 @@ Initialize a documented `.env` from the schema.
|
|
|
288
336
|
Do not read any environment variables
|
|
289
337
|
|
|
290
338
|
```bash
|
|
291
|
-
dnl init --
|
|
339
|
+
dnl init --out .env
|
|
292
340
|
```
|
|
293
341
|
|
|
294
342
|
Useful for:
|
|
@@ -297,18 +345,6 @@ Useful for:
|
|
|
297
345
|
- sharing a template
|
|
298
346
|
- avoiding obsolete `.env.example` files
|
|
299
347
|
|
|
300
|
-
### infer: discover a .envfile, and generate a schema from an existing .env
|
|
301
|
-
|
|
302
|
-
Generate a DNL schema from an existing `.env` file.
|
|
303
|
-
|
|
304
|
-
```bash
|
|
305
|
-
dnl infer --source .env
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
Useful for migrating an existing project
|
|
309
|
-
|
|
310
|
-
→ [Read infer documentation](docs/commands/infer.md)
|
|
311
|
-
|
|
312
348
|
### explain: Display variables documentation
|
|
313
349
|
|
|
314
350
|
Displays the list of known variables and their description.
|
|
@@ -332,73 +368,25 @@ The `export` command transforms variables validated by the schema
|
|
|
332
368
|
into formats directly consumable by other tools (Docker, CI, Kubernetes, scripts…).
|
|
333
369
|
|
|
334
370
|
The schema remains the source of truth.
|
|
335
|
-
Values are validated before export.
|
|
336
|
-
|
|
337
|
-
```bash
|
|
338
|
-
dnl export <format>
|
|
339
|
-
```
|
|
371
|
+
Values are validated before export, and validated AND raw values are passed to the exporter.
|
|
340
372
|
|
|
341
|
-
|
|
342
|
-
A `.env` file can be provided via `--source`.
|
|
343
|
-
|
|
344
|
-
Examples:
|
|
345
|
-
Export environment variables as JSON from a `.env` file
|
|
346
|
-
|
|
347
|
-
```bash
|
|
348
|
-
dnl export json --source .env
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
Clean a `.env` file (remove comments and extraneous lines)
|
|
373
|
+
Example:
|
|
352
374
|
|
|
353
375
|
```bash
|
|
354
|
-
dnl export
|
|
355
|
-
dnl export env --source .env --out .env --force
|
|
376
|
+
dnl export docker-args
|
|
356
377
|
```
|
|
357
378
|
|
|
358
|
-
|
|
379
|
+
Example output:
|
|
359
380
|
|
|
360
381
|
```bash
|
|
361
|
-
|
|
382
|
+
-e NODE_ENV=test -e NODE_PORT=3000 -e FRONT_URL=https://example.com
|
|
362
383
|
```
|
|
363
384
|
|
|
364
|
-
|
|
385
|
+
See DNL documentation for more formats and options :
|
|
386
|
+
→ [Read export documentation](docs/commands/export.md)
|
|
365
387
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
Export for GitHub Actions (variables)
|
|
371
|
-
|
|
372
|
-
```bash
|
|
373
|
-
dnl export github-env
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
Result:
|
|
377
|
-
|
|
378
|
-
```bash
|
|
379
|
-
printf '%s\n' "NODE_ENV=production" >> $GITHUB_ENV
|
|
380
|
-
printf '%s\n' "NODE_PORT=3000" >> $GITHUB_ENV
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
There are a few more formats and options (see CLI docs `dnl export --help`).
|
|
384
|
-
|
|
385
|
-
## export types : Exporting TypeScript types
|
|
386
|
-
|
|
387
|
-
`dnl export types` generates a `.d.ts` file describing the **static contract** of your environment variables.
|
|
388
|
-
|
|
389
|
-
This file is intentionally **conservative**.
|
|
390
|
-
|
|
391
|
-
### Transformed variables
|
|
392
|
-
|
|
393
|
-
If a variable uses a Zod `transform`, the exported type always reflects the **input type**, not the runtime output.
|
|
394
|
-
|
|
395
|
-
In that case:
|
|
396
|
-
|
|
397
|
-
- a warning is emitted in the CLI
|
|
398
|
-
- the generated type is annotated with `@dnl-transform`
|
|
399
|
-
- the runtime value returned by `assert()` may differ
|
|
400
|
-
|
|
401
|
-
This is a deliberate design choice to avoid lying to TypeScript.
|
|
388
|
+
Export command is based on a plugin system, see how to implement your own exporter :
|
|
389
|
+
→ [Read export plugins documentation](docs/commands/export-plugins.md)
|
|
402
390
|
|
|
403
391
|
## Real-life usage
|
|
404
392
|
|
|
@@ -414,6 +402,7 @@ Add `.dnl/` to your `.gitignore`.
|
|
|
414
402
|
Using **dotenv-never-lies** via Git hooks is strongly recommended:
|
|
415
403
|
|
|
416
404
|
- **pre-commit**: prevents committing if the local configuration is not compliant with the schema
|
|
405
|
+
- **pre-commit**: prevents committing if local process.env is used (without annotation)
|
|
417
406
|
- **post-merge**: immediately detects schema changes impacting the local environment
|
|
418
407
|
|
|
419
408
|
The goal is simple:
|
|
@@ -436,11 +425,13 @@ mkdir -p .githooks
|
|
|
436
425
|
cat > .githooks/pre-commit <<'EOF'
|
|
437
426
|
#!/bin/sh
|
|
438
427
|
yarn dnl assert --source .env
|
|
428
|
+
yarn dnl annotate --check --warn-as-error
|
|
439
429
|
EOF
|
|
440
430
|
|
|
441
431
|
cat > .githooks/post-merge <<'EOF'
|
|
442
432
|
#!/bin/sh
|
|
443
433
|
yarn dnl assert --source .env || true
|
|
434
|
+
yarn dnl annotate --check --warn-as-error || true
|
|
444
435
|
EOF
|
|
445
436
|
|
|
446
437
|
chmod +x .githooks/pre-commit .githooks/post-merge
|
|
@@ -533,14 +524,6 @@ This validates the environment before startup, without changing runtime behavior
|
|
|
533
524
|
|
|
534
525
|
> This is optional. It does not replace runtime validation.
|
|
535
526
|
|
|
536
|
-
**Intellisens and JSdoc for env vars**
|
|
537
|
-
|
|
538
|
-
After using `dnl export types` and importing the generated file, you get strong typing, auto-completion, IntelliSense and JSDoc for each environment variable.
|
|
539
|
-
|
|
540
|
-

|
|
541
|
-
|
|
542
|
-
> IntelliSense and JSDoc generated from the DNL schema after `dnl export types`.
|
|
543
|
-
|
|
544
527
|
## Common issues / Troubleshooting
|
|
545
528
|
|
|
546
529
|
### TypeScript projects with `rootDir: "src"`
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|