@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 +1 -1
- package/scripts/copy-public-assets.mjs +42 -34
package/package.json
CHANGED
|
@@ -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"
|
|
10
|
-
const
|
|
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
|
|
26
|
-
["src/landing/team/assets", "assets"],
|
|
27
|
-
];
|
|
13
|
+
const landings = await readdir(srcLandingRoot);
|
|
28
14
|
|
|
29
|
-
|
|
15
|
+
for (const name of landings) {
|
|
16
|
+
const landingPublicDir = join(publicRoot, name);
|
|
17
|
+
await mkdir(landingPublicDir, { recursive: true });
|
|
30
18
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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
|
+
}
|