@backtickjs/builds 0.1.8 → 0.1.10
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 +11 -7
- package/dist/builds.d.ts +7 -2
- package/dist/builds.js +9 -3
- package/dist/builds.js.map +1 -1
- package/dist/moduleMap.d.ts +4 -4
- package/dist/moduleMap.js +26 -15
- package/dist/moduleMap.js.map +1 -1
- package/package.json +2 -2
- package/src/builds.ts +10 -3
- package/src/moduleMap.ts +26 -17
- package/dist/packages.d.ts +0 -14
- package/dist/packages.js +0 -34
- package/dist/packages.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,21 +10,25 @@ npm install @backtickjs/builds
|
|
|
10
10
|
|
|
11
11
|
## How it works
|
|
12
12
|
|
|
13
|
-
1. **The app declares what it offers to screens** in a module map, one per platform as Metro picks files: `moduleMap.ts` for iOS and Android, and `moduleMap.web.ts` for the web. A module map is a table
|
|
13
|
+
1. **The app declares what it offers to screens** in a module map, one per platform as Metro picks files: `moduleMap.ts` for iOS and Android, and `moduleMap.web.ts` for the web. A module map is imports and a table, nothing else, so it can be read without running it:
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
// moduleMap.ts
|
|
17
17
|
import type { ModuleMap } from "@backtickjs/react-native-client";
|
|
18
|
+
import * as React from "react";
|
|
19
|
+
import * as JSXRuntime from "react/jsx-runtime";
|
|
20
|
+
import * as ReactNative from "react-native";
|
|
21
|
+
import * as Facebook from "react-native-fbsdk-next";
|
|
18
22
|
|
|
19
23
|
export const moduleMap = {
|
|
20
|
-
react:
|
|
21
|
-
"react/jsx-runtime":
|
|
22
|
-
"react-native":
|
|
23
|
-
"react-native-fbsdk-next":
|
|
24
|
+
react: React,
|
|
25
|
+
"react/jsx-runtime": JSXRuntime,
|
|
26
|
+
"react-native": ReactNative,
|
|
27
|
+
"react-native-fbsdk-next": Facebook,
|
|
24
28
|
} satisfies ModuleMap;
|
|
25
29
|
```
|
|
26
30
|
|
|
27
|
-
An entry that decides at runtime, like `native
|
|
31
|
+
Each entry is `"specifier": Name`, with `Name` imported above. An entry that decides at runtime, like `native ? Facebook : {}`, is an error. What a platform lacks, its map leaves out.
|
|
28
32
|
|
|
29
33
|
2. **Each build gets an id:** a hash of the modules its platform's map offers, each at the installed version of its package. `app.config.ts` puts the ids in the app config:
|
|
30
34
|
|
|
@@ -91,7 +95,7 @@ npm install @backtickjs/builds
|
|
|
91
95
|
`modulesOf` throws for a build its server can't draw for:
|
|
92
96
|
|
|
93
97
|
- **`UnknownBuild`**: no id, or one that isn't registered. Every build is registered before it ships, so this means the server or the build was deployed wrong, as when a server is rolled back past a build in users' hands. Answer it as a server error.
|
|
94
|
-
- **`DeprecatedBuild`**: a build you retired by setting `"deprecated": true` in its file.
|
|
98
|
+
- **`DeprecatedBuild`**: a build you retired by setting `"deprecated": true` in its file. It carries the build's `modules`, so your server can still draw that build one screen, bundled for what it has: one asking its users to update. Answer every path with it.
|
|
95
99
|
|
|
96
100
|
## API
|
|
97
101
|
|
package/dist/builds.d.ts
CHANGED
|
@@ -15,10 +15,15 @@ export declare class UnknownBuild extends Error {
|
|
|
15
15
|
readonly buildId: string | null;
|
|
16
16
|
constructor(buildId: string | null);
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* A build its server no longer draws its screens for, on purpose. It carries
|
|
20
|
+
* the build's modules, so the server can still draw it one screen, built for
|
|
21
|
+
* what the build has: one asking its users to update.
|
|
22
|
+
*/
|
|
19
23
|
export declare class DeprecatedBuild extends Error {
|
|
20
24
|
readonly buildId: string;
|
|
21
|
-
|
|
25
|
+
readonly modules: Modules;
|
|
26
|
+
constructor(buildId: string, modules: Modules);
|
|
22
27
|
}
|
|
23
28
|
/** Where an app keeps its registered builds, one file each: `builds/`. */
|
|
24
29
|
export declare function buildsDirectory(projectRoot: string): string;
|
package/dist/builds.js
CHANGED
|
@@ -17,12 +17,18 @@ export class UnknownBuild extends Error {
|
|
|
17
17
|
this.buildId = buildId;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* A build its server no longer draws its screens for, on purpose. It carries
|
|
22
|
+
* the build's modules, so the server can still draw it one screen, built for
|
|
23
|
+
* what the build has: one asking its users to update.
|
|
24
|
+
*/
|
|
21
25
|
export class DeprecatedBuild extends Error {
|
|
22
26
|
buildId;
|
|
23
|
-
|
|
27
|
+
modules;
|
|
28
|
+
constructor(buildId, modules) {
|
|
24
29
|
super(`Build ${JSON.stringify(buildId)} is deprecated.`);
|
|
25
30
|
this.buildId = buildId;
|
|
31
|
+
this.modules = modules;
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
34
|
/** Where an app keeps its registered builds, one file each: `builds/`. */
|
|
@@ -67,7 +73,7 @@ export function createBuilds({ projectRoot }) {
|
|
|
67
73
|
modulesOf(buildId) {
|
|
68
74
|
const build = buildId === null ? undefined : registered.get(buildId);
|
|
69
75
|
if (build?.deprecated)
|
|
70
|
-
throw new DeprecatedBuild(buildId);
|
|
76
|
+
throw new DeprecatedBuild(buildId, build.modules);
|
|
71
77
|
if (build !== undefined)
|
|
72
78
|
return build.modules;
|
|
73
79
|
const current = platforms
|
package/dist/builds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builds.js","sourceRoot":"","sources":["../src/builds.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAiB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAW3D;;;;GAIG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACh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AO,UAAU,EAAE,eAAe,QAAQ,2CAA2C,CAAC;YACxF,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,WAAmB;IAEnB,MAAM,SAAS,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC/C,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAChC,MAAM,OAAO,GAAG,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACxD,MAAM,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAmB,UAAU,CAAC,IAAI,CAAC;YAC/C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACxC,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,KAAK,GAAU;YACnB,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACzD,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,KAAK;YACxC,OAAO;SACR,CAAC;QACF,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/moduleMap.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ export declare const platforms: readonly ["ios", "android", "web"];
|
|
|
3
3
|
export type Platform = (typeof platforms)[number];
|
|
4
4
|
/**
|
|
5
5
|
* The specifiers a module map offers, read from its source without running
|
|
6
|
-
* it: `export const moduleMap = { … }`, each entry
|
|
7
|
-
*
|
|
8
|
-
* would make what a build offers something only the
|
|
9
|
-
* throws, naming the line.
|
|
6
|
+
* it: imports, and `export const moduleMap = { … }`, each entry
|
|
7
|
+
* `"specifier": Name` with `Name` bound by an import. Anything more, as a
|
|
8
|
+
* check of the platform, would make what a build offers something only the
|
|
9
|
+
* device knows, so it throws, naming the line.
|
|
10
10
|
*/
|
|
11
11
|
export declare function readModuleMap(file: string): string[];
|
|
12
12
|
/**
|
package/dist/moduleMap.js
CHANGED
|
@@ -8,10 +8,10 @@ export const platforms = ["ios", "android", "web"];
|
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
9
|
/**
|
|
10
10
|
* The specifiers a module map offers, read from its source without running
|
|
11
|
-
* it: `export const moduleMap = { … }`, each entry
|
|
12
|
-
*
|
|
13
|
-
* would make what a build offers something only the
|
|
14
|
-
* throws, naming the line.
|
|
11
|
+
* it: imports, and `export const moduleMap = { … }`, each entry
|
|
12
|
+
* `"specifier": Name` with `Name` bound by an import. Anything more, as a
|
|
13
|
+
* check of the platform, would make what a build offers something only the
|
|
14
|
+
* device knows, so it throws, naming the line.
|
|
15
15
|
*/
|
|
16
16
|
export function readModuleMap(file) {
|
|
17
17
|
const ts = require("typescript");
|
|
@@ -20,10 +20,25 @@ export function readModuleMap(file) {
|
|
|
20
20
|
const { line } = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
21
21
|
return new Error(`${file}:${line + 1}: ${what}`);
|
|
22
22
|
};
|
|
23
|
+
const imported = new Set();
|
|
23
24
|
let map;
|
|
24
25
|
for (const statement of source.statements) {
|
|
25
|
-
if (ts.isImportDeclaration(statement)
|
|
26
|
-
statement.importClause
|
|
26
|
+
if (ts.isImportDeclaration(statement)) {
|
|
27
|
+
const clause = statement.importClause;
|
|
28
|
+
if (clause !== undefined && !clause.isTypeOnly) {
|
|
29
|
+
if (clause.name !== undefined)
|
|
30
|
+
imported.add(clause.name.text);
|
|
31
|
+
const bindings = clause.namedBindings;
|
|
32
|
+
if (bindings !== undefined && ts.isNamespaceImport(bindings)) {
|
|
33
|
+
imported.add(bindings.name.text);
|
|
34
|
+
}
|
|
35
|
+
else if (bindings !== undefined) {
|
|
36
|
+
for (const element of bindings.elements) {
|
|
37
|
+
if (!element.isTypeOnly)
|
|
38
|
+
imported.add(element.name.text);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
continue;
|
|
28
43
|
}
|
|
29
44
|
const declaration = ts.isVariableStatement(statement)
|
|
@@ -40,24 +55,20 @@ export function readModuleMap(file) {
|
|
|
40
55
|
map = value;
|
|
41
56
|
continue;
|
|
42
57
|
}
|
|
43
|
-
throw wrong(statement, "a module map holds `export const moduleMap = { … }`
|
|
58
|
+
throw wrong(statement, "a module map holds imports and `export const moduleMap = { … }` only");
|
|
44
59
|
}
|
|
45
60
|
if (map === undefined) {
|
|
46
|
-
throw new Error(
|
|
61
|
+
throw new Error(file + ": no `export const moduleMap = { … }`");
|
|
47
62
|
}
|
|
48
63
|
return map.properties.map((property) => {
|
|
49
64
|
const entry = ts.isPropertyAssignment(property) &&
|
|
50
65
|
(ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&
|
|
51
|
-
ts.
|
|
52
|
-
property.initializer.
|
|
53
|
-
ts.isCallExpression(property.initializer.body) &&
|
|
54
|
-
property.initializer.body.expression.getText(source) === "require" &&
|
|
55
|
-
property.initializer.body.arguments.length === 1 &&
|
|
56
|
-
ts.isStringLiteral(property.initializer.body.arguments[0])
|
|
66
|
+
ts.isIdentifier(property.initializer) &&
|
|
67
|
+
imported.has(property.initializer.text)
|
|
57
68
|
? property.name
|
|
58
69
|
: undefined;
|
|
59
70
|
if (entry === undefined) {
|
|
60
|
-
throw wrong(property, 'each entry is `"specifier":
|
|
71
|
+
throw wrong(property, 'each entry is `"specifier": Name`, with `Name` imported above');
|
|
61
72
|
}
|
|
62
73
|
return entry.text;
|
|
63
74
|
});
|
package/dist/moduleMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moduleMap.js","sourceRoot":"","sources":["../src/moduleMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,uEAAuE;AACvE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAU,CAAC;AAG5D,4EAA4E;AAC5E,yBAAyB;AACzB,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAgC,CAAC;IAChE,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAChC,IAAI,EACJ,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAC1B,EAAE,CAAC,YAAY,CAAC,MAAM,CACvB,CAAC;IACF,MAAM,KAAK,GAAG,CAAC,IAA+B,EAAE,IAAY,EAAE,EAAE;QAC9D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,6BAA6B,CACnD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CACtB,CAAC;QACF,OAAO,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC;IACF,IAAI,GAA6D,CAAC;IAClE,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1C,
|
|
1
|
+
{"version":3,"file":"moduleMap.js","sourceRoot":"","sources":["../src/moduleM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CAAC,CAAC;QAC3D,IAAI,UAAU,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IACpC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,GAAG,WAAW,mBAAmB,CAAC,CAAC;AACrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backtickjs/builds",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Keeps a Backtick server drawing for every build of its app in users' hands: build ids, a registry of what each build carries, and a check for EAS builds",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backtick",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@backtickjs/bundler": "^0.1.
|
|
43
|
+
"@backtickjs/bundler": "^0.1.10",
|
|
44
44
|
"typescript": "^6.0.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
package/src/builds.ts
CHANGED
|
@@ -35,9 +35,16 @@ export class UnknownBuild extends Error {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* A build its server no longer draws its screens for, on purpose. It carries
|
|
40
|
+
* the build's modules, so the server can still draw it one screen, built for
|
|
41
|
+
* what the build has: one asking its users to update.
|
|
42
|
+
*/
|
|
39
43
|
export class DeprecatedBuild extends Error {
|
|
40
|
-
constructor(
|
|
44
|
+
constructor(
|
|
45
|
+
readonly buildId: string,
|
|
46
|
+
readonly modules: Modules,
|
|
47
|
+
) {
|
|
41
48
|
super(`Build ${JSON.stringify(buildId)} is deprecated.`);
|
|
42
49
|
}
|
|
43
50
|
}
|
|
@@ -107,7 +114,7 @@ export function createBuilds({ projectRoot }: { projectRoot: string }): Builds {
|
|
|
107
114
|
return {
|
|
108
115
|
modulesOf(buildId) {
|
|
109
116
|
const build = buildId === null ? undefined : registered.get(buildId);
|
|
110
|
-
if (build?.deprecated) throw new DeprecatedBuild(buildId
|
|
117
|
+
if (build?.deprecated) throw new DeprecatedBuild(buildId!, build.modules);
|
|
111
118
|
if (build !== undefined) return build.modules;
|
|
112
119
|
const current = platforms
|
|
113
120
|
.map(installedOn)
|
package/src/moduleMap.ts
CHANGED
|
@@ -12,10 +12,10 @@ const require = createRequire(import.meta.url);
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The specifiers a module map offers, read from its source without running
|
|
15
|
-
* it: `export const moduleMap = { … }`, each entry
|
|
16
|
-
*
|
|
17
|
-
* would make what a build offers something only the
|
|
18
|
-
* throws, naming the line.
|
|
15
|
+
* it: imports, and `export const moduleMap = { … }`, each entry
|
|
16
|
+
* `"specifier": Name` with `Name` bound by an import. Anything more, as a
|
|
17
|
+
* check of the platform, would make what a build offers something only the
|
|
18
|
+
* device knows, so it throws, naming the line.
|
|
19
19
|
*/
|
|
20
20
|
export function readModuleMap(file: string): string[] {
|
|
21
21
|
const ts = require("typescript") as typeof import("typescript");
|
|
@@ -30,12 +30,22 @@ export function readModuleMap(file: string): string[] {
|
|
|
30
30
|
);
|
|
31
31
|
return new Error(`${file}:${line + 1}: ${what}`);
|
|
32
32
|
};
|
|
33
|
+
const imported = new Set<string>();
|
|
33
34
|
let map: import("typescript").ObjectLiteralExpression | undefined;
|
|
34
35
|
for (const statement of source.statements) {
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (ts.isImportDeclaration(statement)) {
|
|
37
|
+
const clause = statement.importClause;
|
|
38
|
+
if (clause !== undefined && !clause.isTypeOnly) {
|
|
39
|
+
if (clause.name !== undefined) imported.add(clause.name.text);
|
|
40
|
+
const bindings = clause.namedBindings;
|
|
41
|
+
if (bindings !== undefined && ts.isNamespaceImport(bindings)) {
|
|
42
|
+
imported.add(bindings.name.text);
|
|
43
|
+
} else if (bindings !== undefined) {
|
|
44
|
+
for (const element of bindings.elements) {
|
|
45
|
+
if (!element.isTypeOnly) imported.add(element.name.text);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
39
49
|
continue;
|
|
40
50
|
}
|
|
41
51
|
const declaration = ts.isVariableStatement(statement)
|
|
@@ -56,26 +66,25 @@ export function readModuleMap(file: string): string[] {
|
|
|
56
66
|
}
|
|
57
67
|
throw wrong(
|
|
58
68
|
statement,
|
|
59
|
-
"a module map holds `export const moduleMap = { … }`
|
|
69
|
+
"a module map holds imports and `export const moduleMap = { … }` only",
|
|
60
70
|
);
|
|
61
71
|
}
|
|
62
72
|
if (map === undefined) {
|
|
63
|
-
throw new Error(
|
|
73
|
+
throw new Error(file + ": no `export const moduleMap = { … }`");
|
|
64
74
|
}
|
|
65
75
|
return map.properties.map((property) => {
|
|
66
76
|
const entry =
|
|
67
77
|
ts.isPropertyAssignment(property) &&
|
|
68
78
|
(ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&
|
|
69
|
-
ts.
|
|
70
|
-
property.initializer.
|
|
71
|
-
ts.isCallExpression(property.initializer.body) &&
|
|
72
|
-
property.initializer.body.expression.getText(source) === "require" &&
|
|
73
|
-
property.initializer.body.arguments.length === 1 &&
|
|
74
|
-
ts.isStringLiteral(property.initializer.body.arguments[0]!)
|
|
79
|
+
ts.isIdentifier(property.initializer) &&
|
|
80
|
+
imported.has(property.initializer.text)
|
|
75
81
|
? property.name
|
|
76
82
|
: undefined;
|
|
77
83
|
if (entry === undefined) {
|
|
78
|
-
throw wrong(
|
|
84
|
+
throw wrong(
|
|
85
|
+
property,
|
|
86
|
+
'each entry is `"specifier": Name`, with `Name` imported above',
|
|
87
|
+
);
|
|
79
88
|
}
|
|
80
89
|
return entry.text;
|
|
81
90
|
});
|
package/dist/packages.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type Packages } from "@backtickjs/bundler";
|
|
2
|
-
import { type Platform } from "./moduleMap.js";
|
|
3
|
-
/**
|
|
4
|
-
* The versions of the packages the module map for `platform` offers, as
|
|
5
|
-
* installed in the app at `projectRoot`: what a build made from it now
|
|
6
|
-
* carries there.
|
|
7
|
-
*/
|
|
8
|
-
export declare function installedPackages(projectRoot: string, platform: Platform): Packages;
|
|
9
|
-
/**
|
|
10
|
-
* The id of a build that carries `packages`: a hash of them, so two builds
|
|
11
|
-
* that carry the same share it, and a build always names exactly what it
|
|
12
|
-
* has.
|
|
13
|
-
*/
|
|
14
|
-
export declare function buildIdOf(packages: Packages): string;
|
package/dist/packages.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { packageOf } from "@backtickjs/bundler";
|
|
5
|
-
import { moduleMapFile, readModuleMap } from "./moduleMap.js";
|
|
6
|
-
/**
|
|
7
|
-
* The versions of the packages the module map for `platform` offers, as
|
|
8
|
-
* installed in the app at `projectRoot`: what a build made from it now
|
|
9
|
-
* carries there.
|
|
10
|
-
*/
|
|
11
|
-
export function installedPackages(projectRoot, platform) {
|
|
12
|
-
const specifiers = readModuleMap(moduleMapFile(projectRoot, platform));
|
|
13
|
-
const names = [...new Set(specifiers.map(packageOf))].sort();
|
|
14
|
-
return Object.fromEntries(names.map((name) => {
|
|
15
|
-
const file = join(projectRoot, "node_modules", name, "package.json");
|
|
16
|
-
const { version } = JSON.parse(readFileSync(file, "utf8"));
|
|
17
|
-
return [name, version];
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The id of a build that carries `packages`: a hash of them, so two builds
|
|
22
|
-
* that carry the same share it, and a build always names exactly what it
|
|
23
|
-
* has.
|
|
24
|
-
*/
|
|
25
|
-
export function buildIdOf(packages) {
|
|
26
|
-
const sorted = Object.keys(packages)
|
|
27
|
-
.sort()
|
|
28
|
-
.map((name) => [name, packages[name]]);
|
|
29
|
-
return createHash("sha256")
|
|
30
|
-
.update(JSON.stringify(sorted))
|
|
31
|
-
.digest("hex")
|
|
32
|
-
.slice(0, 16);
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=packages.js.map
|
package/dist/packages.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"packages.js","sourceRoot":"","sources":["../src/packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAiB,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAiB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE7E;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,WAAmB,EACnB,QAAkB;IAElB,MAAM,UAAU,GAAG,aAAa,CAAC,aAAa,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,OAAO,MAAM,CAAC,WAAW,CACvB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACrE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAExD,CAAC;QACF,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,QAAkB;IAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,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