@jjlmoya/landings 0.6.0 → 0.7.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": "@jjlmoya/landings",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,4 +1,5 @@
1
- import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
1
+ import { cp, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
2
+ import { existsSync } from "node:fs";
2
3
  import { dirname, join } from "node:path";
3
4
  import { fileURLToPath } from "node:url";
4
5
 
@@ -6,41 +7,48 @@ const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
6
7
  const consumerRoot = packageRoot.includes("node_modules")
7
8
  ? join(packageRoot, "../../..")
8
9
  : packageRoot;
9
- const publicRoot = join(consumerRoot, "public", "landings", "team");
10
- const styleFiles = [
11
- "team-landing.css",
12
- "TeamHero.css",
13
- "CompanyWorks.css",
14
- "BobMasterPlan.css",
15
- "TeamComicScenes.css",
16
- "HumanTouch.css",
17
- "ProductManifesto.css",
18
- "BobModelBook.css",
19
- "SupportTransition.css",
20
- "MemoryWall.css",
21
- "TeamRoster.css",
22
- "BehindJoke.css",
23
- ];
10
+ const publicRoot = join(consumerRoot, "public", "landings");
11
+ const srcLandingRoot = join(packageRoot, "src", "landing");
24
12
 
25
- const copies = [
26
- ["src/landing/team/assets", "assets"],
27
- ];
13
+ const landings = await readdir(srcLandingRoot);
28
14
 
29
- await mkdir(publicRoot, { recursive: true });
15
+ for (const name of landings) {
16
+ const landingPublicDir = join(publicRoot, name);
17
+ await mkdir(landingPublicDir, { recursive: true });
30
18
 
31
- for (const [from, to] of copies) {
32
- await cp(join(packageRoot, from), join(publicRoot, to), {
33
- recursive: true,
34
- force: true,
35
- errorOnExist: false,
36
- });
37
- }
19
+ const stylesRoot = join(srcLandingRoot, name, "styles");
20
+ let hasStyles = false;
21
+ try {
22
+ const styleFiles = (await readdir(stylesRoot)).filter((f) =>
23
+ f.endsWith(".css"),
24
+ );
25
+ if (styleFiles.length > 0) {
26
+ const cssBundle = await Promise.all(
27
+ styleFiles.map(async (file) => {
28
+ const content = await readFile(join(stylesRoot, file), "utf8");
29
+ return `/* ${file} */\n${content.trim()}\n`;
30
+ }),
31
+ );
32
+ await writeFile(
33
+ join(landingPublicDir, `${name}.css`),
34
+ `${cssBundle.join("\n")}\n`,
35
+ );
36
+ hasStyles = true;
37
+ }
38
+ } catch {
39
+ // no styles dir
40
+ }
38
41
 
39
- const cssBundle = await Promise.all(
40
- styleFiles.map(async (file) => {
41
- const content = await readFile(join(packageRoot, "src", "landing", "team", "styles", file), "utf8");
42
- return `/* ${file} */\n${content.trim()}\n`;
43
- }),
44
- );
42
+ if (!hasStyles) {
43
+ console.log(`[landings] No styles found for "${name}"`);
44
+ }
45
45
 
46
- await writeFile(join(publicRoot, "team.css"), `${cssBundle.join("\n")}\n`);
46
+ const assetsDir = join(srcLandingRoot, name, "assets");
47
+ if (existsSync(assetsDir)) {
48
+ await cp(assetsDir, join(landingPublicDir, "assets"), {
49
+ recursive: true,
50
+ force: true,
51
+ errorOnExist: false,
52
+ });
53
+ }
54
+ }