@socketsecurity/cli 0.14.43 → 0.14.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +16 -38
  2. package/bin/cli.js +17 -7
  3. package/bin/npm-cli.js +1 -1
  4. package/bin/npx-cli.js +1 -1
  5. package/dist/constants.d.ts +121 -11
  6. package/dist/constants.js +91 -10
  7. package/dist/constants.js.map +1 -0
  8. package/dist/init.gradle +250 -0
  9. package/dist/module-sync/cli.js +6115 -3842
  10. package/dist/module-sync/cli.js.map +1 -0
  11. package/dist/module-sync/edge.d.ts +66 -0
  12. package/dist/module-sync/errors.d.ts +6 -1
  13. package/dist/module-sync/index.d.ts +192 -0
  14. package/dist/module-sync/index.js +1879 -0
  15. package/dist/module-sync/index.js.map +1 -0
  16. package/dist/module-sync/logging.d.ts +3 -3
  17. package/dist/module-sync/node.d.ts +84 -0
  18. package/dist/module-sync/npm-injection.js +7 -1486
  19. package/dist/module-sync/npm-injection.js.map +1 -0
  20. package/dist/module-sync/npm-paths.d.ts +3 -2
  21. package/dist/module-sync/npm-paths.js +91 -42
  22. package/dist/module-sync/npm-paths.js.map +1 -0
  23. package/dist/module-sync/npm.d.ts +24 -0
  24. package/dist/module-sync/npm.js +99 -0
  25. package/dist/module-sync/npm.js.map +1 -0
  26. package/dist/module-sync/path-resolve.d.ts +1 -1
  27. package/dist/module-sync/proc-log.d.ts +3 -0
  28. package/dist/module-sync/reify.d.ts +1018 -0
  29. package/dist/module-sync/sdk.d.ts +5 -0
  30. package/dist/module-sync/settings.d.ts +5 -4
  31. package/dist/module-sync/shadow-bin.d.ts +1 -1
  32. package/dist/module-sync/shadow-bin.js +33 -16
  33. package/dist/module-sync/shadow-bin.js.map +1 -0
  34. package/dist/module-sync/types.d.ts +45 -0
  35. package/dist/require/cli.js +6114 -3842
  36. package/dist/require/constants.js +1 -1
  37. package/dist/require/index.js +3 -0
  38. package/dist/require/npm.js +3 -0
  39. package/dist/require/vendor.js +2336 -6
  40. package/package.json +69 -42
  41. package/dist/constants.d.ts.map +0 -1
  42. package/dist/module-sync/socket-url.d.ts +0 -40
  43. package/dist/module-sync/socket-url.js +0 -301
  44. package/dist/require/socket-url.js +0 -3
@@ -0,0 +1,250 @@
1
+ // This is a Gradle initialization script that generates Maven POM files for projects
2
+ // A POM file describes a project's dependencies and other metadata in XML format
3
+
4
+ // This script:
5
+ // - Generates Maven POM files for Java/Kotlin/Android projects
6
+ // - Handles different types of dependencies (direct, project, version catalog)
7
+ // - Supports different project types (Java, Android, root project)
8
+ // - Can be invoked with `./gradlew --init-script /path/to/this/script pom` to generate POM files
9
+ // - Copies the generated POM to a target location (default: pom.xml)
10
+
11
+ initscript {
12
+ repositories {
13
+ // We need these repositories for Gradle's plugin resolution system
14
+ // TODO: it's not clear if we actually need them.
15
+ gradlePluginPortal()
16
+ mavenCentral()
17
+ google()
18
+ }
19
+
20
+ dependencies {
21
+ // No external dependencies needed as we only use Gradle's built-in maven-publish plugin
22
+ }
23
+ }
24
+
25
+ // Apply these configurations to all projects in the build
26
+ gradle.allprojects { project ->
27
+ // Create a unique name for the Maven publication
28
+ // Example: project ':foo:bar' becomes 'maven-foo-bar'
29
+ def publicationName = "maven-${project.path.replace(':', '-')}"
30
+ if (publicationName.startsWith('maven--')) {
31
+ publicationName = 'maven-root' // Special case for root project
32
+ }
33
+
34
+ // Apply the Maven Publish plugin if not already applied
35
+ if (!project.plugins.hasPlugin('maven-publish')) {
36
+ project.plugins.apply('maven-publish')
37
+ }
38
+
39
+ // Register a new task called 'pom' that will generate the POM file.
40
+ // This is what allows us to do `gradlew pom`. We could rename it to
41
+ // something like socket-generate-pom instead. It should be invisible
42
+ // to the user because this script is not part of their repo.
43
+ project.tasks.register('pom') {
44
+ group = 'publishing' // Group tasks are shown together in ./gradlew tasks (irrelevant)
45
+ description = 'Generates a POM file'
46
+ // Force task to run every time. Otherwise caching would cause
47
+ // subsequent runs without changes to do anything.
48
+ // There may be room for improvement; I think this may cause
49
+ // everything to run which is theorietically not necessary.
50
+ outputs.upToDateWhen { false }
51
+
52
+ // Define where POM files will be generated and copied
53
+ def defaultPomFile = project.file("build/publications/${publicationName}/pom-default.xml")
54
+ def targetPomFile = project.hasProperty('pomPath') ?
55
+ project.file(project.property('pomPath')) : // Custom location if specified. You can use `./gradlew pom -PpomPath=path/to/pom.xml` to specify a custom location.
56
+ project.file('pom.xml') // Default location
57
+
58
+ // Declare task inputs and outputs for Gradle's incremental build system
59
+ inputs.file(defaultPomFile)
60
+ outputs.file(targetPomFile)
61
+
62
+ // The actual work of copying the POM file happens here
63
+ doLast {
64
+ if (defaultPomFile.exists()) {
65
+ // Print the generated POM for inspection
66
+ println "\nGenerated POM file for ${publicationName}:"
67
+ // println "=================================="
68
+ // println defaultPomFile.text
69
+ // println "=================================="
70
+
71
+ // Copy the POM file to its target location
72
+ targetPomFile.parentFile.mkdirs()
73
+ targetPomFile.text = defaultPomFile.text
74
+ println "\nPOM file copied to: ${targetPomFile.absolutePath}"
75
+ } else {
76
+ println "No POM file generated at ${defaultPomFile.absolutePath}"
77
+ }
78
+ }
79
+ }
80
+
81
+ // Wait for project evaluation to complete before configuring publication
82
+ project.afterEvaluate { p ->
83
+ p.plugins.withId('maven-publish') {
84
+ // Gather project information
85
+ def projectPath = p.path
86
+ def projectName = p.name
87
+ def projectDesc = p.description ?: p.name
88
+ def isRootProject = p.path == ':' && !p.subprojects.isEmpty()
89
+ def isAndroidProject = p.plugins?.hasPlugin('com.android.library') ||
90
+ p.plugins?.hasPlugin('com.android.application')
91
+ def hasJavaComponent = p.extensions?.findByName('components')?.findByName('java') != null
92
+
93
+ // Store all dependencies we find here
94
+ def projectDependencies = []
95
+
96
+ // Find all relevant dependency configurations
97
+ // We care about implementation, api, compile, and runtime configurations
98
+ // TODO: anything we're missing here? tests maybe?
99
+ def relevantConfigs = p.configurations.findAll { config ->
100
+ !config.name.toLowerCase().contains('test') &&
101
+ (config.name.endsWith('Implementation') ||
102
+ config.name.endsWith('Api') ||
103
+ config.name == 'implementation' ||
104
+ config.name == 'api' ||
105
+ config.name == 'compile' ||
106
+ config.name == 'runtime')
107
+ }
108
+
109
+ // Process each configuration to find dependencies
110
+ relevantConfigs.each { config ->
111
+ config.dependencies.each { dep ->
112
+ if (dep instanceof ProjectDependency) {
113
+ // Handle project dependencies (e.g., implementation(project(":other-module")))
114
+ def depProjectPath = dep.dependencyProject.path
115
+ def depProjectName = depProjectPath.substring(depProjectPath.lastIndexOf(':') + 1)
116
+ projectDependencies << [
117
+ group: p.group ?: p.rootProject.name,
118
+ name: depProjectName,
119
+ version: p.version ?: 'unspecified',
120
+ scope: config.name.contains('api') ? 'compile' : 'runtime'
121
+ ]
122
+ } else {
123
+ // Handle all other types of dependencies
124
+ try {
125
+ def group = dep.group
126
+ def name = dep.name
127
+ def version = dep.version
128
+
129
+ // Handle version catalog dependencies (e.g., implementation(libs.some.library))
130
+ if (!group && p.findProperty('libs')) {
131
+ def depString = dep.toString()
132
+
133
+ // Skip bundles and file dependencies as they need special handling
134
+ if (!depString.contains('Bundle') && !dep.toString().contains('DefaultFileCollectionDependency')) {
135
+ try {
136
+ // Extract library name from version catalog reference
137
+ def libName = depString.contains('libs.') ?
138
+ depString.substring(depString.indexOf('libs.') + 5) :
139
+ depString
140
+ def libProvider = p.libs.findLibrary(libName)
141
+ if (libProvider.present) {
142
+ def dependency = libProvider.get()
143
+ projectDependencies << [
144
+ group: dependency.get().module.group,
145
+ name: dependency.get().module.name,
146
+ version: dependency.versionConstraint.requiredVersion,
147
+ scope: config.name.contains('api') ? 'compile' : 'runtime'
148
+ ]
149
+ }
150
+ } catch (Exception e) {
151
+ println " - Skipping non-catalog dependency: ${dep}"
152
+ }
153
+ }
154
+ } else if (group && name) {
155
+ // Handle regular dependencies (e.g., implementation("group:name:version"))
156
+ projectDependencies << [
157
+ group: group,
158
+ name: name,
159
+ version: version ?: 'unspecified',
160
+ scope: config.name.contains('api') ? 'compile' : 'runtime'
161
+ ]
162
+ }
163
+ } catch (Exception e) {
164
+ println " - Failed to process dependency: ${e.message}"
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+ // Configure the Maven publication
171
+ p.publishing {
172
+ publications {
173
+ if (!publications.findByName(publicationName)) {
174
+ create(publicationName, MavenPublication) {
175
+ // Handle different project types
176
+ if (isAndroidProject) {
177
+ // For Android libraries, we need to wait for the Android plugin to set up
178
+ afterEvaluate {
179
+ def android = p.extensions.findByName('android')
180
+ if (android) {
181
+ // Try to get the release variant component
182
+ def components = p.components
183
+ def componentNames = components.names
184
+
185
+ // Look for specific variant components
186
+ // Prefer release over debug
187
+ if (components.findByName("release")) {
188
+ from components.release
189
+ } else if (components.findByName("debug")) {
190
+ from components.debug
191
+ } else {
192
+ println "Warning: No release or debug component found for Android project ${p.name}"
193
+ // Skip the component for now, will still generate POM
194
+ }
195
+ } else {
196
+ println "Warning: Android extension not found for project ${p.name}"
197
+ }
198
+ }
199
+ } else if (!isRootProject && hasJavaComponent) {
200
+ // For Java libraries, use the java component
201
+ from components.java
202
+ }
203
+ // Root project doesn't need a 'from' clause as it's just a POM
204
+
205
+ // Configure the POM file content
206
+ pom {
207
+ // Set packaging type based on project type (why is this necessary?)
208
+ packaging = isRootProject ? 'pom' : (isAndroidProject ? 'aar' : 'jar')
209
+ name = projectName
210
+ description = projectDesc
211
+
212
+ // Customize the POM XML
213
+ withXml { xml ->
214
+ def root = xml.asNode()
215
+ def dependencies = root.appendNode('dependencies')
216
+
217
+ // Add all collected dependencies to the POM
218
+ projectDependencies.each { dep ->
219
+ def dependency = dependencies.appendNode('dependency')
220
+ // Ensure all values are strings
221
+ dependency.appendNode('groupId', String.valueOf(dep.group))
222
+ dependency.appendNode('artifactId', String.valueOf(dep.name))
223
+ dependency.appendNode('version', String.valueOf(dep.version ?: 'unspecified'))
224
+ dependency.appendNode('scope', String.valueOf(dep.scope))
225
+ }
226
+
227
+ // Add standard properties for root project
228
+ if (isRootProject) {
229
+ def properties = root.appendNode('properties')
230
+ properties.appendNode('kotlin.version', String.valueOf('1.9.0'))
231
+ properties.appendNode('java.version', String.valueOf('11'))
232
+ properties.appendNode('project.build.sourceEncoding', String.valueOf('UTF-8'))
233
+ }
234
+ }
235
+ }
236
+ }
237
+ }
238
+ }
239
+ }
240
+
241
+ // Make our pom task depend on the actual POM generation task
242
+ project.tasks.named('pom') {
243
+ def pomTask = "generatePomFileFor${publicationName.capitalize()}Publication"
244
+ if (project.tasks?.findByName(pomTask)) {
245
+ dependsOn(pomTask)
246
+ }
247
+ }
248
+ }
249
+ }
250
+ }