@contentsquare/react-native-cli 1.0.0 → 1.1.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/dist/auth.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ interface AuthResponse {
2
+ access_token: string;
3
+ expires_in: number;
4
+ scope: string;
5
+ token_type: string;
6
+ project_id: string;
7
+ endpoint: string;
8
+ }
9
+ export declare const authenticate: (clientId: string, clientSecret: string, projectId: string, baseUrl: string) => Promise<AuthResponse>;
10
+ export {};
11
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAGA,UAAU,YAAY;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,YAAY,aACb,MAAM,gBACF,MAAM,aACT,MAAM,WACR,MAAM,KACd,QAAQ,YAAY,CAkBtB,CAAC"}
@@ -0,0 +1,34 @@
1
+ interface Config {
2
+ android: {
3
+ clientId?: string;
4
+ clientSecret?: string;
5
+ projectId?: string;
6
+ sourcemapPath?: string;
7
+ uploadUrl?: string;
8
+ };
9
+ ios: {
10
+ clientId?: string;
11
+ clientSecret?: string;
12
+ projectId?: string;
13
+ sourcemapPath?: string;
14
+ uploadUrl?: string;
15
+ };
16
+ }
17
+ interface Options {
18
+ clientId?: string;
19
+ clientSecret?: string;
20
+ platform?: string;
21
+ projectId?: string | number;
22
+ sourcemapPath?: string;
23
+ uploadUrl?: string;
24
+ config?: string;
25
+ }
26
+ /**
27
+ * Creates a configuration object based on the provided options and config file.
28
+ * @param {Options} options - The options object.
29
+ * @param {string} configPath - The path to the config file.
30
+ * @returns {Config} - The configuration object.
31
+ */
32
+ export declare const createConfig: (options: Options, configPath?: string) => Config;
33
+ export {};
34
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,UAAU,MAAM;IACd,OAAO,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,GAAG,EAAE;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,UAAU,OAAO;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,YAAa,OAAO,eAAe,MAAM,KAAG,MA8CpE,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ type LogLevel = 'verbose' | 'info' | 'warn' | 'error' | 'success';
2
+ export declare const setLogLevel: (level: LogLevel) => void;
3
+ export declare const log: {
4
+ verbose: (...messages: any[]) => void;
5
+ info: (...messages: any[]) => void;
6
+ success: (...messages: any[]) => void;
7
+ warn: (...messages: any[]) => void;
8
+ error: (...messages: any[]) => void;
9
+ };
10
+ export {};
11
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAGA,KAAK,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAIlE,eAAO,MAAM,WAAW,UAAW,QAAQ,KAAG,IAE7C,CAAC;AAsCF,eAAO,MAAM,GAAG;2BACS,GAAG,EAAE;wBACR,GAAG,EAAE;2BACF,GAAG,EAAE;wBACR,GAAG,EAAE;yBACJ,GAAG,EAAE;CAC3B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const updateSourcemapId: (platforms: Array<'ios' | 'android'>) => void;
2
+ export declare const saveSourcemapId: (platform: string, id: string) => void;
3
+ export declare const readSourcemapId: (platform: string) => string;
4
+ //# sourceMappingURL=sourcemap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourcemap.d.ts","sourceRoot":"","sources":["../src/sourcemap.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,iBAAiB,cACjB,MAAM,KAAK,GAAG,SAAS,CAAC,KAClC,IAYF,CAAC;AAEF,eAAO,MAAM,eAAe,aAAc,MAAM,MAAM,MAAM,KAAG,IAqB9D,CAAC;AAEF,eAAO,MAAM,eAAe,aAAc,MAAM,KAAG,MAoBlD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const uploadSourcemap: (filePath: string, platform: string, sourcemapId: string, tokenType: string, authToken: string, baseUrl: string) => Promise<void>;
2
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,eAAe,aAChB,MAAM,YACN,MAAM,eACH,MAAM,aACR,MAAM,aACN,MAAM,WACR,MAAM,KACd,QAAQ,IAAI,CAsDd,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Adds https prefix to a URL if not already present.
3
+ * @param {string} url - The URL to check and modify.
4
+ * @returns {string} - The URL with https prefix.
5
+ */
6
+ export declare const ensureHttps: (url: string) => string;
7
+ /**
8
+ * Returns the exclusive platform selection based on the input, defaults to both platforms.
9
+ * @param {string} platform - The platform to check.
10
+ * @returns {Array<'ios' | 'android'>} - The platform selection.
11
+ */
12
+ export declare const getPlatformSelection: (platform?: 'ios' | 'android') => Array<'ios' | 'android'>;
13
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,MAKzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,cACpB,KAAK,GAAG,SAAS,KAC3B,MAAM,KAAK,GAAG,SAAS,CAEzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentsquare/react-native-cli",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool from Contentsquare to upload source maps for React Native apps",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -11,6 +11,7 @@
11
11
  "/README.md",
12
12
  "/LICENSE",
13
13
  "/dist/",
14
+ "!/dist/tsconfig.tsbuildinfo",
14
15
  "/bin/",
15
16
  "/scripts/"
16
17
  ],
@@ -25,7 +26,8 @@
25
26
  "postinstall": "chmod +x ./scripts/contentsquare-xcode.sh && chmod +x ./scripts/ios-config.sh"
26
27
  },
27
28
  "dependencies": {
28
- "axios": "^1.15.0",
29
+ "axios": "^1.19.0",
30
+ "chalk": "^4.1.2",
29
31
  "commander": "^7.2.0",
30
32
  "fs": "0.0.2",
31
33
  "path": "0.12.7",
@@ -38,5 +40,8 @@
38
40
  "jest": "^29.7.0",
39
41
  "ts-jest": "^29.2.5",
40
42
  "typescript": "^4.0.0"
43
+ },
44
+ "installConfig": {
45
+ "hoistingLimits": "workspaces"
41
46
  }
42
47
  }
@@ -125,18 +125,29 @@ private def getContentsquareCLIExecPath(reactConfig) {
125
125
 
126
126
  def nodeExecutable = Os.isFamily(Os.FAMILY_WINDOWS) ? 'node.exe' : 'node'
127
127
  def nodeScript = '''
128
+ const fs = require('fs');
128
129
  const path = require('path');
130
+ const cliName = 'contentsquare-cli';
129
131
  const modulePath = require.resolve('@contentsquare/react-native-cli/package.json');
130
- const cliPath = path.resolve(path.dirname(modulePath), '../../.bin/contentsquare-cli');
131
- console.log(cliPath);
132
+ // Regular install: the package lives in <node_modules>/@contentsquare/react-native-cli, so its
133
+ // executable is in <node_modules>/.bin. In a workspace the package is symlinked and resolves to
134
+ // its real location, so also look in every node_modules folder visible from here.
135
+ const candidates = [
136
+ path.resolve(path.dirname(modulePath), '../../.bin', cliName),
137
+ ...require.resolve.paths('@contentsquare/react-native-cli').map(dir => path.join(dir, '.bin', cliName)),
138
+ ];
139
+ console.log(candidates.find(candidate => fs.existsSync(candidate)) || candidates[0]);
132
140
  '''
133
141
 
134
- return executeNodeScript(nodeExecutable, nodeScript) ?: defaultPath
142
+ return executeNodeScript(nodeExecutable, nodeScript, project.file(reactConfig.root.toString())) ?: defaultPath
135
143
  }
136
144
 
137
- private def executeNodeScript(String executable, String script) {
145
+ private def executeNodeScript(String executable, String script, File workingDir) {
138
146
  try {
147
+ // Run from the React root so that require.resolve looks up the app's node_modules, not those
148
+ // of whatever folder the Gradle daemon happens to have been started from.
139
149
  def process = new ProcessBuilder(executable)
150
+ .directory(workingDir)
140
151
  .redirectErrorStream(true)
141
152
  .start()
142
153