@produtype/core 1.21.2 → 1.23.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.
@@ -247,6 +247,19 @@ function isTestOrExamplePath(file) {
247
247
  * and it says which build the file is part of.
248
248
  */
249
249
  || /(^|\/)config\/(test|dev)\.exs$/i.test(file)
250
+ /**
251
+ * Gradle's source sets, which name the build they belong to.
252
+ *
253
+ * `src/androidTest/` is instrumentation tests and `src/test/` is unit tests;
254
+ * neither is compiled into the shipped application, and `src/main/` is. davx5
255
+ * keeps an `AndroidManifest.xml` in `core/src/androidTest/` declaring three
256
+ * permissions its tests need, and the report opened its permission finding with
257
+ * that file — a test's manifest offered as the app's permission surface.
258
+ *
259
+ * The same argument as `_test.go` and `config/test.exs`: the directory name is
260
+ * the toolchain's, not the author's, and it says which build the file is part of.
261
+ */
262
+ || /(^|\/)src\/(androidTest|test)\//i.test(file)
250
263
  || /(^|\/)test[-_][^/]+\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(file)
251
264
  /**
252
265
  * The other half of the convention.
@@ -232,7 +232,20 @@ async function detectMobile(ctx) {
232
232
  });
233
233
  }
234
234
  }
235
- for (const file of androidFiles.filter((f) => /AndroidManifest\.xml$/i.test(f))) {
235
+ /**
236
+ * Gradle names the source set a file belongs to, and `androidTest` is not shipped.
237
+ *
238
+ * davx5 keeps an `AndroidManifest.xml` in `core/src/androidTest/` declaring the
239
+ * three permissions its instrumentation tests need, and the permission finding
240
+ * opened with that file: a test's manifest offered as the application's permission
241
+ * surface. `src/main/` is what goes into the APK.
242
+ *
243
+ * Filtered here rather than in the path rule that excludes `_test.go` and
244
+ * `config/test.exs`, because these manifests are read from the whole file list and
245
+ * never pass through it.
246
+ */
247
+ const SHIPPED_SOURCE_SET = (file) => !/(^|\/)src\/(androidTest|test)\//i.test(file);
248
+ for (const file of androidFiles.filter((f) => /AndroidManifest\.xml$/i.test(f) && SHIPPED_SOURCE_SET(f))) {
236
249
  const text = (await (0, readTextFileSafe_1.readTextFileSafe)(ctx.root, file)) ?? '';
237
250
  const declared = [...text.matchAll(/<uses-permission[^>]*android:name="([^"]+)"/g)].map(([, name]) => name);
238
251
  // Android has no purpose strings, so the equivalent evidence is asking at the
@@ -253,6 +266,24 @@ async function detectMobile(ctx) {
253
266
  /request\(\)\s*;?\s*\/\/\s*permission/,
254
267
  /PermissionsAndroid\.request/,
255
268
  /requestPermissionsAsync/,
269
+ /**
270
+ * How Android asks for a permission now, in the two libraries Google publishes.
271
+ *
272
+ * davx5 shows a switch per permission and calls
273
+ * `state::launchMultiplePermissionRequest` when somebody turns one on —
274
+ * Accompanist's API, which is asking at the moment of use as plainly as it can
275
+ * be asked. It was told at `high` that it gives no reason for any of the twelve
276
+ * permissions it declares.
277
+ *
278
+ * `ActivityResultContracts.RequestPermission` is the AndroidX contract that
279
+ * replaced `ActivityCompat.requestPermissions`, and
280
+ * `rememberMultiplePermissionsState` is Accompanist's. Both names belong to
281
+ * Google; what the launcher is called afterwards belongs to the author, which
282
+ * is why the pattern stops at the contract.
283
+ */
284
+ /ActivityResultContracts\.RequestMultiplePermissions|ActivityResultContracts\.RequestPermission\b/,
285
+ /remember(?:Multiple)?Permissions?State\s*\(/,
286
+ /launch(?:Multiple)?Permissions?Request\b/,
256
287
  ], 3);
257
288
  for (const match of runtimeRequests) {
258
289
  permissionsExplained = true;
@@ -59,10 +59,17 @@ async function detectObservability(ctx) {
59
59
  * these are the same statement in another manifest.
60
60
  */
61
61
  const DOTNET_LOGGING_PACKAGES = ['NLog', 'NLog.Extensions.Logging', 'Serilog', 'Serilog.AspNetCore', 'Microsoft.Extensions.Logging', 'log4net'];
62
+ /**
63
+ * Go names its logging in go.mod, and the same argument as .NET applies: the module
64
+ * path is the ecosystem's, and a project that imports zerolog logs structurally
65
+ * whatever it calls its own logger.
66
+ */
67
+ const GO_LOGGING_PACKAGES = ['rs/zerolog', 'sirupsen/logrus', 'go.uber.org/zap', 'uber-go/zap', 'phuslu/log'];
62
68
  const logDeps = [
63
69
  ...(0, detectContext_1.hasAnyDep)(ctx, LOGGING_PACKAGES),
64
70
  ...(0, detectContext_1.hasAnyElixirDep)(ctx, ELIXIR_LOGGING_PACKAGES),
65
71
  ...(0, detectContext_1.hasAnyDotnetDep)(ctx, DOTNET_LOGGING_PACKAGES),
72
+ ...(0, detectContext_1.hasAnyGoDep)(ctx, GO_LOGGING_PACKAGES),
66
73
  ];
67
74
  const sentryDeps = (0, detectContext_1.hasAnyDep)(ctx, ['@sentry/node', 'sentry-sdk']);
68
75
  for (const d of logDeps)
@@ -177,6 +184,19 @@ async function detectObservability(ctx) {
177
184
  */
178
185
  /Monolog\\Logger|LoggerInterface|->(info|warning|error|debug)\(/,
179
186
  /\bslog\.(Info|Warn|Error|Debug)\(|\bzap\.|\blogrus\.|\blog\.Printf\(/,
187
+ /**
188
+ * zerolog builds the entry instead of formatting it.
189
+ *
190
+ * `log.Error().Err(err).Msg("Error updating last used")` is how gotify logs
191
+ * every line of its Go server, and none of the shapes beside this one is a
192
+ * chain: they all expect the level to take the message. gotify's logging was
193
+ * read from `console.error` in its React admin instead — the frontend
194
+ * describing a failed delete, offered as how the server records what happened.
195
+ *
196
+ * `.Msg(` and `.Msgf(` after a level are zerolog's and zap's sugared API both,
197
+ * and neither is a name the author chose.
198
+ */
199
+ /\b(?:log|logger)\.(?:Info|Warn|Warning|Error|Debug|Fatal|Trace)\(\)(?:\.\w+\([^)]*\))*\.Msgf?\(/,
180
200
  /LoggerFactory\.getLogger|org\.slf4j/,
181
201
  /Rails\.logger/,
182
202
  /\btracing::(info|warn|error|debug)!|\blog::(info|warn|error)!/,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@produtype/core",
3
- "version": "1.21.2",
3
+ "version": "1.23.0",
4
4
  "description": "Deterministic CLI and library that analyzes a web application repository and reports how far it is from production-ready for the kind of product it is meant to be.",
5
5
  "license": "MIT",
6
6
  "bin": {