h1v3 0.11.0 → 0.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h1v3",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -1,35 +1,23 @@
1
1
  import fs from "node:fs/promises";
2
2
  import { existsSync } from "node:fs";
3
- import { dirname, join, resolve } from "node:path";
3
+ import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
+ import me from "../package.js";
5
6
 
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
-
8
- async function readPackageJSON() {
9
-
10
- return JSON.parse(await fs.readFile(`${__dirname}/../../package.json`));
7
+ const packageName = `${me.name}@${me.version}`;
11
8
 
12
- }
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
10
 
14
11
  async function vendor(subpath) {
15
12
 
16
13
  const src = join(__dirname, "..", "..", "dist", "browser", subpath);;
17
14
 
18
15
  // Destination: include semver
19
- const versionedName = await versionedPackageName();
20
- const dest =join(destVendorPath(), versionedName, subpath);
16
+ const dest =join(destVendorPath(), packageName, subpath);
21
17
 
22
18
  // Recursive copy
23
19
  await fs.cp(src, dest, { recursive: true });
24
- console.log(`Vendored ${versionedName}/${subpath} -> ${dest}`);
25
-
26
- }
27
-
28
- async function versionedPackageName() {
29
-
30
- const { version, name } = await readPackageJSON();
31
- const versionedName = `${name}@${version}`;
32
- return versionedName;
20
+ console.log(`Vendored ${packageName}/${subpath} -> ${dest}`);
33
21
 
34
22
  }
35
23
 
@@ -39,18 +27,6 @@ function destVendorPath() {
39
27
 
40
28
  }
41
29
 
42
- // export async function eventStore(_argv) {
43
-
44
- // await vendor("event-store");
45
-
46
- // }
47
-
48
- // export async function webPlatform(_argv) {
49
-
50
- // await vendor("web");
51
-
52
- // }
53
-
54
30
  export async function deps(_argv) {
55
31
 
56
32
  // lit
@@ -78,28 +54,6 @@ export async function client(_argv) {
78
54
 
79
55
  }
80
56
 
81
- // export async function webPlatformUI(_argv) {
82
-
83
- // await webPlatform(_argv);
84
- // await vendor("web-ui");
85
- // const resp = await fetch("https://cdn.jsdelivr.net/gh/lit/dist@3.3.1/core/lit-core.min.js")
86
- // const lit = await resp.text();
87
- // const dest = join(".", "public", "vendor", "lit@3.3.1", "dist");
88
- // await fs.mkdir(dest, { recursive: true });
89
- // await fs.writeFile(
90
- // join(".", "public", "vendor", "lit@3.3.1", "dist", "lit-core.min.js"),
91
- // lit
92
- // );
93
-
94
- // }
95
-
96
- // export async function membership(_argv) {
97
-
98
- // await eventStore(_argv);
99
- // await vendor("team");
100
-
101
- // }
102
-
103
57
  export async function symLinkLatest(_argv) {
104
58
 
105
59
  const vendorPath = destVendorPath();
@@ -28,6 +28,10 @@ export const teamInviteToEmailMapping = ({ team: { membership: { path } } }) =>
28
28
 
29
29
  `root.child('${path}/${PROJECTIONS}/inviteToEmail')`;
30
30
 
31
+ export const assertTeamDoesNotExist = ({ team: { membership: { path } } }) =>
32
+
33
+ `!root.child('${path}').exists()`;
34
+
31
35
  export const assertDoesNotAlreadyExist =
32
36
 
33
37
  "!data.exists()";
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { listEventStores } from "./commands/list-event-stores.js";
4
4
  import { generateRules } from "./commands/generate-rules.js";
@@ -2,7 +2,7 @@ import details from "./projections/details.js";
2
2
  import members from "./projections/members.js";
3
3
  import inviteToEmail from "./projections/inviteToEmail.js";
4
4
 
5
- import { eventTypes, INVITE_ACCEPTED, INVITE_REJECTED } from "./events.js";
5
+ import { BECAME_ADMIN, eventTypes, INVITE_ACCEPTED, INVITE_REJECTED } from "./events.js";
6
6
  import {
7
7
  newDataPayloadId,
8
8
  assertPayloadUidMyUserId,
@@ -12,10 +12,12 @@ import {
12
12
  teamInviteToEmailMapping,
13
13
  any,
14
14
  all,
15
- assertEventIsOfType
15
+ assertEventIsOfType,
16
+ assertTeamDoesNotExist
16
17
  } from "../../configuration/rules.js";
17
18
  import { verifyStorePaths } from "../team-details/verify-store-paths.js";
18
19
 
20
+
19
21
  export function store(paths) {
20
22
 
21
23
  verifyStorePaths(paths, {
@@ -44,6 +46,12 @@ export function store(paths) {
44
46
 
45
47
  )
46
48
 
49
+ ),
50
+ all(
51
+
52
+ assertTeamDoesNotExist(paths),
53
+ assertEventIsOfType(BECAME_ADMIN),
54
+ assertPayloadUidMyUserId
47
55
  )
48
56
 
49
57
  ),
package/src/package.js ADDED
@@ -0,0 +1,32 @@
1
+ import { readFileSync } from "fs";
2
+ import { dirname } from "path";
3
+ import { fileURLToPath } from "url";
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+
7
+ export default {
8
+
9
+ get version() {
10
+
11
+ return ensure().version;
12
+
13
+ },
14
+
15
+ get name() {
16
+
17
+ return ensure().name;
18
+
19
+ }
20
+
21
+ }
22
+
23
+ function ensure() {
24
+
25
+ if (!ensure.json) {
26
+
27
+ ensure.json = JSON.parse(readFileSync(`${__dirname}/../package.json`));
28
+
29
+ }
30
+ return ensure.json;
31
+
32
+ }
@@ -1,5 +1,6 @@
1
1
  import minimist from "minimist";
2
2
  import { loadConfiguration } from "../configuration/load-configuration.js"
3
+ import me from "../package.js";
3
4
 
4
5
  export async function main(commands) {
5
6
 
@@ -45,6 +46,7 @@ async function invoke(commands, verb, argv) {
45
46
 
46
47
  function displayHelp(commands) {
47
48
 
49
+ console.log("Version", me.version);
48
50
  console.log("Help:");
49
51
  console.log("");
50
52