@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
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DNL_ANNOTATION } from "../report.type.js";
|
|
2
|
+
import { getLinkToVar } from "../../ast-tools/ast-helpers.js";
|
|
3
|
+
import { hasDnlAnnotation } from "../helper.js";
|
|
4
|
+
import { getDefaultEnvValue } from "../../cli/utils/printer.js";
|
|
5
|
+
export const addAnnotationRule = {
|
|
6
|
+
match(usages) {
|
|
7
|
+
// If at least one has no annotation, we need to add the annotation
|
|
8
|
+
return usages.some((u) => !hasDnlAnnotation(u.anchor, undefined));
|
|
9
|
+
},
|
|
10
|
+
async apply(usages, ctx) {
|
|
11
|
+
const issues = [];
|
|
12
|
+
const anchor = usages[0].anchor;
|
|
13
|
+
const old = anchor.getText();
|
|
14
|
+
const indentMatch = old.match(/^\s*/);
|
|
15
|
+
const indent = indentMatch ? indentMatch[0] : "";
|
|
16
|
+
const body = old.trimStart();
|
|
17
|
+
// Build an object to know the comment characteristics
|
|
18
|
+
for (const u of usages) {
|
|
19
|
+
const issue = {
|
|
20
|
+
nodeText: u.node.getText(),
|
|
21
|
+
annotation: null,
|
|
22
|
+
messages: [],
|
|
23
|
+
pos: u.pos,
|
|
24
|
+
};
|
|
25
|
+
switch (u.kind) {
|
|
26
|
+
case "destructured":
|
|
27
|
+
case "static":
|
|
28
|
+
if (u.varName in ctx.envDef.def) {
|
|
29
|
+
issue.annotation = DNL_ANNOTATION.recommendation;
|
|
30
|
+
const link = getLinkToVar(ctx.project, ctx.schemaPath, u.varName);
|
|
31
|
+
const defaultValue = getDefaultEnvValue(ctx.envDef.def[u.varName].schema.def);
|
|
32
|
+
issue.messages.push(`// @see ${u.varName} in your DNL schema : ${link}`);
|
|
33
|
+
if (defaultValue) {
|
|
34
|
+
issue.messages.push(`// default value: ${defaultValue}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
issue.annotation = DNL_ANNOTATION.ignore;
|
|
39
|
+
issue.messages.push(`// process.env.${u.varName} not in your DNL schema`);
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case "dynamic":
|
|
43
|
+
issue.annotation = DNL_ANNOTATION.dynamic;
|
|
44
|
+
issue.messages.push(`// Dynamic access to process.env prevents variable-level analysis`);
|
|
45
|
+
break;
|
|
46
|
+
case "global":
|
|
47
|
+
issue.annotation = DNL_ANNOTATION.global;
|
|
48
|
+
issue.messages.push(`// Global access to process.env prevents variable-level analysis`);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
issues.push(issue);
|
|
52
|
+
}
|
|
53
|
+
// Concat all issues to one unique comment (for one statement).
|
|
54
|
+
const lines = [];
|
|
55
|
+
lines.push(`// ${issues.map((issue) => issue.annotation).join(" ")}`);
|
|
56
|
+
// Deduplicate messages
|
|
57
|
+
const messages = [...new Set(issues.flatMap((issue) => issue.messages))];
|
|
58
|
+
for (const message of messages) {
|
|
59
|
+
lines.push(message);
|
|
60
|
+
}
|
|
61
|
+
// Apply indentation to each comment line
|
|
62
|
+
const comment = lines.map((line) => `${indent}${line}`).join("\n");
|
|
63
|
+
// Reinsert the original statement with its indentation
|
|
64
|
+
anchor.replaceWithText(`${comment}\n${indent}${body}`);
|
|
65
|
+
return issues;
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/annotate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,YAAY,EAAE,YA6B1B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Node } from "ts-morph";
|
|
2
|
+
import { getLinkToVar } from "../helper.js";
|
|
3
|
+
import { getDefaultEnvValue } from "../../cli/utils/printer.js";
|
|
4
|
+
export const fallbackRule = {
|
|
5
|
+
name: "recommendation",
|
|
6
|
+
match(node) {
|
|
7
|
+
if (node.getText().includes("@dnl-annotation"))
|
|
8
|
+
return false;
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
async apply(node, ctx) {
|
|
12
|
+
// match() garantit déjà que c'est un PropertyAccessExpression sur process.env
|
|
13
|
+
const varName = node.getName();
|
|
14
|
+
const statement = node.getFirstAncestor((n) => Node.isStatement(n));
|
|
15
|
+
if (statement) {
|
|
16
|
+
const old = statement.getText();
|
|
17
|
+
const link = getLinkToVar(ctx.project, ctx.schemaPath, varName);
|
|
18
|
+
const defaultValue = getDefaultEnvValue(ctx.envDef.def[varName].schema.def);
|
|
19
|
+
let comment = `// @dnl-annotation ${this.name}\n// @see ${varName} in your DNL schema : ${link}`;
|
|
20
|
+
if (defaultValue)
|
|
21
|
+
comment += `\n// default value: ${defaultValue}`;
|
|
22
|
+
statement.replaceWithText(`${comment}\n${old}`);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
level: "warning",
|
|
26
|
+
message: "unsupported process.env usage",
|
|
27
|
+
action: "comment-added",
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,eAAO,MAAM,mBAAmB,EAAE,YAwDjC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DNL_ANNOTATION } from "../report.type.js";
|
|
2
|
+
import { getDnlAnnotationType, hasDnlAnnotation } from "../helper.js";
|
|
3
|
+
export const checkAnnotationRule = {
|
|
4
|
+
match(processEnvAccesses) {
|
|
5
|
+
function matchOne(pea) {
|
|
6
|
+
if (!hasDnlAnnotation(pea.anchor))
|
|
7
|
+
return true;
|
|
8
|
+
if (getDnlAnnotationType(pea.anchor) === DNL_ANNOTATION.ignore)
|
|
9
|
+
return false;
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return processEnvAccesses.some((pea) => matchOne(pea));
|
|
13
|
+
},
|
|
14
|
+
async apply(processEnvAccesses) {
|
|
15
|
+
const issues = [];
|
|
16
|
+
for (let i = 0; i < processEnvAccesses.length; i++) {
|
|
17
|
+
const pea = processEnvAccesses[i];
|
|
18
|
+
const noAnnotationIssue = {
|
|
19
|
+
annotation: null,
|
|
20
|
+
messages: [`No DNL annotation found for ${pea.node.getText()}`],
|
|
21
|
+
checkLevel: "error",
|
|
22
|
+
nodeText: pea.node.getText(),
|
|
23
|
+
};
|
|
24
|
+
const anchor = pea.anchor;
|
|
25
|
+
// No annotation => Error!
|
|
26
|
+
if (!anchor || !hasDnlAnnotation(anchor)) {
|
|
27
|
+
issues.push(noAnnotationIssue);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
// If we have an annotation, retrieve it and create the corresponding issue.
|
|
31
|
+
const annotation = getDnlAnnotationType(anchor);
|
|
32
|
+
const issue = {
|
|
33
|
+
nodeText: pea.node.getText(),
|
|
34
|
+
annotation,
|
|
35
|
+
messages: [],
|
|
36
|
+
pos: pea.pos,
|
|
37
|
+
};
|
|
38
|
+
switch (annotation) {
|
|
39
|
+
case null:
|
|
40
|
+
issues.push(noAnnotationIssue);
|
|
41
|
+
break;
|
|
42
|
+
case DNL_ANNOTATION.ignore:
|
|
43
|
+
// Normally this case is filtered out by match before reaching apply.
|
|
44
|
+
// We keep the case to produce an empty/absurd result, but it should not happen.
|
|
45
|
+
issue.checkLevel = "info";
|
|
46
|
+
issues.push(issue);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
issue.checkLevel = "warning";
|
|
50
|
+
issues.push(issue);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return issues;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/fallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,YAAY,EAAE,YAoC1B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Node } from "ts-morph";
|
|
2
|
+
import { getLinkToVar } from "../helper.js";
|
|
3
|
+
import { getDefaultEnvValue } from "../../cli/utils/printer.js";
|
|
4
|
+
export const fallbackRule = {
|
|
5
|
+
name: "fallback-unsupported-usage",
|
|
6
|
+
match(node) {
|
|
7
|
+
if (node.getText().includes("@dnl-process-annotation"))
|
|
8
|
+
return false;
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
async apply(node, ctx) {
|
|
12
|
+
// match() garantit déjà que c'est un PropertyAccessExpression sur process.env
|
|
13
|
+
const varName = node.getName();
|
|
14
|
+
//console.log("fallbackRule apply");
|
|
15
|
+
const statement = node.getFirstAncestor((n) => Node.isStatement(n));
|
|
16
|
+
// console.log("sourceFile : ", ctx.sourceFile.getFilePath());
|
|
17
|
+
// console.log("statement : ", statement?.getText());
|
|
18
|
+
if (statement) {
|
|
19
|
+
const old = statement.getText();
|
|
20
|
+
const link = getLinkToVar(ctx.project, ctx.schemaPath, varName);
|
|
21
|
+
const defaultValue = getDefaultEnvValue(ctx.envDef.def[varName].schema.def);
|
|
22
|
+
let comment = `// @dnl-process-annotation ${this.name}\n// @see ${varName} in your DNL schema : ${link}`;
|
|
23
|
+
if (defaultValue)
|
|
24
|
+
comment += `\n// default value: ${defaultValue}`;
|
|
25
|
+
statement.replaceWithText(`${comment}\n${old}`);
|
|
26
|
+
//const result = statement.replaceWithText(`// @dnl-warning unsupported process.env usage\n${old}`);
|
|
27
|
+
// console.log("statement replaced : ", result?.getText());
|
|
28
|
+
console.log("defaultValue : ", defaultValue);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
level: "warning",
|
|
32
|
+
message: "unsupported process.env usage",
|
|
33
|
+
action: "comment-added",
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/ignore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,eAAO,MAAM,kBAAkB,EAAE,YAuChC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Node } from "ts-morph";
|
|
2
|
+
import { DNL_ANNOTATION } from "../report.type.js";
|
|
3
|
+
import { getAnnotationStatement, hasDnlAnnotation } from "../helper.js";
|
|
4
|
+
export const warnUnknownVarRule = {
|
|
5
|
+
annotation: DNL_ANNOTATION.ignore,
|
|
6
|
+
match(node, ctx) {
|
|
7
|
+
if (!Node.isPropertyAccessExpression(node))
|
|
8
|
+
return false;
|
|
9
|
+
const statement = getAnnotationStatement(node);
|
|
10
|
+
console.log("warnUnknownVarRule this.annotation", this.annotation);
|
|
11
|
+
if (statement && hasDnlAnnotation(statement, this.annotation))
|
|
12
|
+
return false;
|
|
13
|
+
const expr = node.getExpression();
|
|
14
|
+
if (expr.getText() !== "process.env")
|
|
15
|
+
return false;
|
|
16
|
+
// skip when it's a DNL var (defined in schema)
|
|
17
|
+
const varName = node.getName();
|
|
18
|
+
const envDefKeys = Object.keys(ctx.envDef.def);
|
|
19
|
+
if (envDefKeys.includes(varName)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
console.log("warnUnknownVarRule return true");
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
async apply(node) {
|
|
26
|
+
// match() already guarantees this is a PropertyAccessExpression on process.env
|
|
27
|
+
const varName = node.getName();
|
|
28
|
+
const statement = getAnnotationStatement(node);
|
|
29
|
+
if (statement) {
|
|
30
|
+
const old = statement.getText();
|
|
31
|
+
statement.replaceWithText(`// @dnl-ignore reason : TODO\n${old}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log("warnUnknownVarRule no statement found");
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
message: `DNL ignore process.env.${varName}`,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-env-var.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/process-env-var.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,eAAO,MAAM,kBAAkB,EAAE,YA0ChC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Node } from "ts-morph";
|
|
2
|
+
export const AnnotateEnvVarRule = {
|
|
3
|
+
name: "process-env-var",
|
|
4
|
+
match(node) {
|
|
5
|
+
if (!Node.isPropertyAccessExpression(node))
|
|
6
|
+
return false;
|
|
7
|
+
const expr = node.getExpression();
|
|
8
|
+
if (expr.getText() !== "process.env")
|
|
9
|
+
return false;
|
|
10
|
+
const parent = node.getParent();
|
|
11
|
+
// On refuse tout usage plus complexe que l'accès direct
|
|
12
|
+
if (Node.isBinaryExpression(parent) || Node.isConditionalExpression(parent) || Node.isCallExpression(parent)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
// LIMITER aux types scalaires. et encore .... !
|
|
16
|
+
// // ici
|
|
17
|
+
// // if is dnl var !
|
|
18
|
+
// const varName = node.getName();
|
|
19
|
+
// if (ctx.asserter.def[varName].secret) {
|
|
20
|
+
// return false;
|
|
21
|
+
// }
|
|
22
|
+
return true;
|
|
23
|
+
},
|
|
24
|
+
async apply(node) {
|
|
25
|
+
if (!Node.isPropertyAccessExpression(node)) {
|
|
26
|
+
throw new Error("process-env-var applied on non PropertyAccessExpression");
|
|
27
|
+
}
|
|
28
|
+
const varName = node.getName();
|
|
29
|
+
node.replaceWithText(`env.${varName}`);
|
|
30
|
+
return {
|
|
31
|
+
level: "warning",
|
|
32
|
+
message: "unsupported process.env usage",
|
|
33
|
+
action: "replaced",
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommandation.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/recommandation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,YAAY,EAAE,YA6B1B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DNL_ANNOTATION } from "../report.type.js";
|
|
2
|
+
import { Node } from "ts-morph";
|
|
3
|
+
import { getAnnotationStatement, getLinkToVar, hasDnlAnnotation } from "../helper.js";
|
|
4
|
+
import { getDefaultEnvValue } from "../../cli/utils/printer.js";
|
|
5
|
+
export const fallbackRule = {
|
|
6
|
+
annotation: DNL_ANNOTATION.recommendation,
|
|
7
|
+
match(node) {
|
|
8
|
+
console.log("fallbackRule this.annotation", this.annotation);
|
|
9
|
+
const statement = getAnnotationStatement(node);
|
|
10
|
+
if (statement && hasDnlAnnotation(statement, this.annotation))
|
|
11
|
+
return false;
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
async apply(node, ctx) {
|
|
15
|
+
// match() already guarantees this is a PropertyAccessExpression on process.env
|
|
16
|
+
const varName = node.getName();
|
|
17
|
+
const statement = node.getFirstAncestor((n) => Node.isStatement(n));
|
|
18
|
+
if (statement) {
|
|
19
|
+
const old = statement.getText();
|
|
20
|
+
const link = getLinkToVar(ctx.project, ctx.schemaPath, varName);
|
|
21
|
+
const defaultValue = getDefaultEnvValue(ctx.envDef.def[varName].schema.def);
|
|
22
|
+
let comment = `// ${this.annotation}\n// @see ${varName} in your DNL schema : ${link}`;
|
|
23
|
+
if (defaultValue)
|
|
24
|
+
comment += `\n// default value: ${defaultValue}`;
|
|
25
|
+
statement.replaceWithText(`${comment}\n${old}`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
message: `DNL recommend usage of env.${varName}, instead of process.env.${varName}`,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-annotation.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/remove-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,eAAO,MAAM,oBAAoB,EAAE,YAgDlC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DNL_ANNOTATION } from "../report.type.js";
|
|
2
|
+
import { Node } from "ts-morph";
|
|
3
|
+
import { getAnchor, getDnlAnnotation, hasDnlAnnotation } from "../helper.js";
|
|
4
|
+
export const removeAnnotationRule = {
|
|
5
|
+
match(node) {
|
|
6
|
+
if (!Node.isPropertyAccessExpression(node))
|
|
7
|
+
return false;
|
|
8
|
+
if (node.getExpression().getText() !== "process.env")
|
|
9
|
+
return false;
|
|
10
|
+
const anchor = getAnchor(node);
|
|
11
|
+
if (!anchor)
|
|
12
|
+
return false;
|
|
13
|
+
// pas annoté ? on se tait
|
|
14
|
+
if (!hasDnlAnnotation(anchor, undefined)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
},
|
|
19
|
+
async apply(node) {
|
|
20
|
+
const varName = node.getName();
|
|
21
|
+
const statement = getAnchor(node);
|
|
22
|
+
if (!statement) {
|
|
23
|
+
console.log("No DNL annotation found for process.env.${varName}");
|
|
24
|
+
return { annotation: DNL_ANNOTATION.ignore, message: `No DNL annotation found for process.env.${varName}` };
|
|
25
|
+
}
|
|
26
|
+
const dnlAnnotation = getDnlAnnotation(statement);
|
|
27
|
+
if (!dnlAnnotation) {
|
|
28
|
+
console.log("No DNL annotation found for process.env.${varName}");
|
|
29
|
+
return { annotation: DNL_ANNOTATION.ignore, message: `No DNL annotation found for process.env.${varName}` };
|
|
30
|
+
}
|
|
31
|
+
const { ranges, annotationType } = dnlAnnotation;
|
|
32
|
+
if (!ranges || ranges.length < 1) {
|
|
33
|
+
console.log("No DNL annotation found for process.env.${varName}");
|
|
34
|
+
return { annotation: DNL_ANNOTATION.ignore, message: `No DNL annotation found for process.env.${varName}` };
|
|
35
|
+
}
|
|
36
|
+
// Remplace the whole block of annotations (comments) by _nothing_,
|
|
37
|
+
// to keep only the statement (ex. « const nodeEnv = process.env.NODE_ENV || "development"; »).
|
|
38
|
+
// Do not modify here : the command will apply the removalRange in batch (descending order).
|
|
39
|
+
const first = ranges[0];
|
|
40
|
+
// Include everything up to the beginning of the statement to also delete the empty lines between comments and code.
|
|
41
|
+
const removalRange = { start: first.getPos(), end: statement.getStart() };
|
|
42
|
+
return {
|
|
43
|
+
annotation: annotationType,
|
|
44
|
+
message: `DNL annotation removed for process.env.${varName}`,
|
|
45
|
+
removalRange,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/remove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,eAAO,MAAM,oBAAoB,EAAE,YA4ClC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getDnlAnnotation, hasDnlAnnotation } from "../helper.js";
|
|
2
|
+
export const removeAnnotationRule = {
|
|
3
|
+
match(processEnvAccesses) {
|
|
4
|
+
// If at least one has an annotation, we need to remove it
|
|
5
|
+
if (processEnvAccesses.some((pea) => hasDnlAnnotation(pea.anchor)))
|
|
6
|
+
return true;
|
|
7
|
+
return false;
|
|
8
|
+
},
|
|
9
|
+
async apply(processEnvAccesses) {
|
|
10
|
+
// We want to remove the comments added by the Add rule.
|
|
11
|
+
// Add takes the same parameter as remove.
|
|
12
|
+
// Add builds a single comment for all AnnotateEnvRuleIssue in a group.
|
|
13
|
+
// So we only have one block to remove, the first we find!
|
|
14
|
+
// But we still try to detect all annotations we are going to remove.
|
|
15
|
+
const issues = [];
|
|
16
|
+
let detected = false;
|
|
17
|
+
const hasAnnotation = hasDnlAnnotation(processEnvAccesses[0].anchor);
|
|
18
|
+
const dnlAnnotation = getDnlAnnotation(processEnvAccesses[0].anchor);
|
|
19
|
+
const ranges = dnlAnnotation?.ranges ?? [];
|
|
20
|
+
const first = ranges.reduce((min, r) => (r.getPos() < min.getPos() ? r : min), ranges[0]);
|
|
21
|
+
for (let i = 0; i < processEnvAccesses.length; i++) {
|
|
22
|
+
if (!hasAnnotation || !dnlAnnotation || dnlAnnotation.ranges.length < 1) {
|
|
23
|
+
// We should not be here!
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const pea = processEnvAccesses[i];
|
|
27
|
+
const annotation = dnlAnnotation?.annotationTypes?.[i] ?? null;
|
|
28
|
+
const removalRange = { start: first?.getPos() ?? 0, end: pea.anchor.getStart() };
|
|
29
|
+
const issue = {
|
|
30
|
+
nodeText: pea.node.getText(),
|
|
31
|
+
annotation,
|
|
32
|
+
messages: [],
|
|
33
|
+
pos: pea.pos,
|
|
34
|
+
removalRange: detected ? undefined : removalRange,
|
|
35
|
+
};
|
|
36
|
+
issues.push(issue);
|
|
37
|
+
detected = true;
|
|
38
|
+
}
|
|
39
|
+
return issues;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-annotation.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/simple-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,oBAAoB,EAAE,YAiDlC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DNL_ANNOTATION } from "../report.type.js";
|
|
2
|
+
import { Node } from "ts-morph";
|
|
3
|
+
import { getAnchor, getLinkToVar, hasDnlAnnotation } from "../helper.js";
|
|
4
|
+
import { getDefaultEnvValue } from "../../cli/utils/printer.js";
|
|
5
|
+
export const simpleAnnotationRule = {
|
|
6
|
+
match(node) {
|
|
7
|
+
if (!Node.isPropertyAccessExpression(node))
|
|
8
|
+
return false;
|
|
9
|
+
if (node.getExpression().getText() !== "process.env")
|
|
10
|
+
return false;
|
|
11
|
+
const anchor = getAnchor(node);
|
|
12
|
+
if (!anchor)
|
|
13
|
+
return false;
|
|
14
|
+
// déjà annoté ? on se tait
|
|
15
|
+
if (hasDnlAnnotation(anchor, undefined)) {
|
|
16
|
+
console.log("simpleAnnotationRule already annotated, return false");
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
},
|
|
21
|
+
async apply(node, ctx) {
|
|
22
|
+
// match() already guarantees this is a PropertyAccessExpression on process.env
|
|
23
|
+
const varName = node.getName();
|
|
24
|
+
const statement = getAnchor(node);
|
|
25
|
+
if (!statement)
|
|
26
|
+
throw new Error("No statement found");
|
|
27
|
+
const old = statement.getText();
|
|
28
|
+
const isKnown = varName in ctx.envDef.def;
|
|
29
|
+
let annotation;
|
|
30
|
+
let comment;
|
|
31
|
+
let message;
|
|
32
|
+
if (isKnown) {
|
|
33
|
+
// @dnl-annotation
|
|
34
|
+
annotation = DNL_ANNOTATION.recommendation;
|
|
35
|
+
const link = getLinkToVar(ctx.project, ctx.schemaPath, varName);
|
|
36
|
+
const defaultValue = getDefaultEnvValue(ctx.envDef.def[varName].schema.def);
|
|
37
|
+
comment = `// ${annotation}`;
|
|
38
|
+
if (link)
|
|
39
|
+
comment += `\n// @see ${varName} in your DNL schema : ${link}`;
|
|
40
|
+
if (defaultValue)
|
|
41
|
+
comment += `\n// default value: ${defaultValue}`;
|
|
42
|
+
message = `DNL recommend usage of env.${varName}, instead of process.env.${varName}`;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
//@dnl-ignore reason : TODO
|
|
46
|
+
annotation = DNL_ANNOTATION.ignore;
|
|
47
|
+
comment = `// ${annotation} reason : TODO`;
|
|
48
|
+
message = `DNL ignore process.env.${varName}`;
|
|
49
|
+
}
|
|
50
|
+
statement.replaceWithText(`${comment}\n${old}`);
|
|
51
|
+
return { annotation, message };
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn-unknown-var.d.ts","sourceRoot":"","sources":["../../../src/annotate/rules/warn-unknown-var.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,eAAO,MAAM,kBAAkB,EAAE,YAyChC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Node } from "ts-morph";
|
|
2
|
+
export const warnUnknownVarRule = {
|
|
3
|
+
name: "process-env-not-in-schema",
|
|
4
|
+
match(node, ctx) {
|
|
5
|
+
if (!Node.isPropertyAccessExpression(node))
|
|
6
|
+
return false;
|
|
7
|
+
const expr = node.getExpression();
|
|
8
|
+
if (expr.getText() !== "process.env")
|
|
9
|
+
return false;
|
|
10
|
+
// const parent = node.getParent();
|
|
11
|
+
// ici
|
|
12
|
+
// if is not adnl var !
|
|
13
|
+
const varName = node.getName();
|
|
14
|
+
const envDefKeys = Object.keys(ctx.envDef.def);
|
|
15
|
+
if (envDefKeys.includes(varName)) {
|
|
16
|
+
console.log("varName : ", varName + ` is a dnl var => ignored by ${this.name} rule`);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
console.log("varName : ", varName + ` is a not => ${this.name} should apply`);
|
|
20
|
+
return true;
|
|
21
|
+
},
|
|
22
|
+
async apply(node) {
|
|
23
|
+
// match() garantit déjà que c'est un PropertyAccessExpression sur process.env
|
|
24
|
+
const varName = node.getName();
|
|
25
|
+
const statement = node.getFirstAncestor((n) => Node.isStatement(n));
|
|
26
|
+
// console.log("sourceFile : ", ctx.sourceFile.getFilePath());
|
|
27
|
+
// console.log("statement : ", statement?.getText());
|
|
28
|
+
if (statement) {
|
|
29
|
+
const old = statement.getText();
|
|
30
|
+
statement.replaceWithText(`// @dnl-process-annotation ${this.name} \n// process.env.${varName} is not declared in env.dnl\n${old}`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
level: "warning",
|
|
34
|
+
message: `process.env.${varName} is not declared in env.dnl`,
|
|
35
|
+
action: "comment-added",
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Project, SourceFile } from "ts-morph";
|
|
2
|
+
import type { AnnotateEnvRuleIssue, AnnotateMode, AnnotateReport, DNLAnnotationType } from "./report.type.js";
|
|
3
|
+
import { EnvDefinition, EnvDefinitionHelper } from "../index.js";
|
|
4
|
+
import { ProcessEnvUsages } from "../ast-tools/ast.types.js";
|
|
5
|
+
export type AnnotateRuleContext = {
|
|
6
|
+
mode: AnnotateMode;
|
|
7
|
+
warnAsError: boolean;
|
|
8
|
+
project: Project;
|
|
9
|
+
sourceFile: SourceFile;
|
|
10
|
+
schemaPath: string;
|
|
11
|
+
envDef: EnvDefinitionHelper<EnvDefinition>;
|
|
12
|
+
report: AnnotateReport;
|
|
13
|
+
};
|
|
14
|
+
export interface AnnotateRule {
|
|
15
|
+
/**
|
|
16
|
+
* Unique rule annotation (used for debug, logs, tests)
|
|
17
|
+
*/
|
|
18
|
+
annotation?: DNLAnnotationType;
|
|
19
|
+
/**
|
|
20
|
+
* Return true if this rule can handle the given AST node
|
|
21
|
+
*/
|
|
22
|
+
match(usages: ProcessEnvUsages[], ctx: AnnotateRuleContext): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Apply the rule. Receives all process.env nodes from the same statement.
|
|
25
|
+
* - In check mode: must NOT mutate the AST
|
|
26
|
+
* - In fix mode: MAY mutate the AST
|
|
27
|
+
*/
|
|
28
|
+
apply(usages: ProcessEnvUsages[], ctx: AnnotateRuleContext): Promise<AnnotateEnvRuleIssue[]>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/annotate/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC9G,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAE/B;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC;IAErE;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;CAChG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Node, Project, type Statement } from "ts-morph";
|
|
2
|
+
import { ProcessEnvUsages } from "./ast.types.js";
|
|
3
|
+
export declare const getAnchor: (node: Node) => Statement | null;
|
|
4
|
+
/** All process.env accesses grouped by statement (key = statement.getStart()). */
|
|
5
|
+
export declare const groupProcessEnvUsagesByStatementMap: (usages: ProcessEnvUsages[]) => Map<number, ProcessEnvUsages[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the environment variable name for a process.env.X or process.env["X"] node.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getProcessEnvVarName: (node: Node) => string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Get the link to a variable in the schema file
|
|
12
|
+
* @param project : the ts-morph project
|
|
13
|
+
* @param schemaPath : the path to the schema file
|
|
14
|
+
* @param varName : the name of the variable to get the link to
|
|
15
|
+
* @returns the link to the variable in the schema file
|
|
16
|
+
*/
|
|
17
|
+
export declare const getLinkToVar: (project: Project, schemaPath: string, varName: string) => string | null;
|
|
18
|
+
export declare const getRelativeFilePath: (node: Node) => string;
|
|
19
|
+
//# sourceMappingURL=ast-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-helpers.d.ts","sourceRoot":"","sources":["../../src/ast-tools/ast-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,SAAS,EAA+D,MAAM,UAAU,CAAC;AACtH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,SAAS,GAAI,MAAM,IAAI,KAAG,SAAS,GAAG,IAElD,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,mCAAmC,GAAI,QAAQ,gBAAgB,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAW9G,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,IAAI,KAAG,MAAM,GAAG,IAe1D,CAAC;AAKF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,EAAE,YAAY,MAAM,EAAE,SAAS,MAAM,KAAG,MAAM,GAAG,IA+B7F,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,MAAM,IAAI,KAAG,MAKhD,CAAC"}
|