@atomicsmash/compiler 1.1.0-beta.3 → 2.0.0-beta.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/cli.js CHANGED
@@ -8,12 +8,10 @@ import { config as defaultConfig } from "./config.js";
8
8
  const argv = await yargs(hideBin(process.argv))
9
9
  .options({
10
10
  in: {
11
- demandOption: true,
12
11
  describe: "The directory where the source files can be found. Relative to cwd.",
13
12
  type: "string",
14
13
  },
15
14
  out: {
16
- demandOption: true,
17
15
  describe: "The directory where the compiled files will out output. Relative to cwd.",
18
16
  type: "string",
19
17
  },
@@ -41,13 +39,6 @@ const argv = await yargs(hideBin(process.argv))
41
39
  })
42
40
  .showHelpOnFail(false, "Specify --help for available options")
43
41
  .parse();
44
- // const explorer = cosmiconfig("smash-compiler");
45
- // const config = await explorer.search().then(async (config) => {
46
- // if (!config) {
47
- // return await defaultConfig({ ...argv });
48
- // }
49
- // return config.config as Configuration;
50
- // });
51
42
  const compiler = webpack(await defaultConfig({ ...argv }));
52
43
  if (argv.watch) {
53
44
  const watching = compiler.watch({
package/dist/config.d.ts CHANGED
@@ -14,11 +14,11 @@ export declare function config(options: {
14
14
  /**
15
15
  * The directory where the source files can be found. Relative to cwd.
16
16
  */
17
- in: string;
17
+ in?: string;
18
18
  /**
19
19
  * The directory where the compiled files will out output. Relative to cwd.
20
20
  */
21
- out: string;
21
+ out?: string;
22
22
  /**
23
23
  * Whether to watch the files in the source folder for changes and compile.
24
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,QAAQ,EAAe,MAAM,SAAS,CAAC;AAQpE,OAAO,iCAAiC,MAAM,iDAAiD,CAAC;AAEhG,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,g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AO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAsB,MAAM,CAAC,OAAO,EAAE;IACrC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChD;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA4L6B,QAAQ;;;;;;;;;;;qCAeX,QAAQ;;;;;;;;;;sCA3PrB,CAAC;;;;;;;;;;;;;;;;;;;;;GA0bd"}
package/dist/config.js CHANGED
@@ -1,5 +1,6 @@
1
- import { sep as pathSeparator, extname, resolve as resolvePath, relative, } from "node:path";
1
+ import { sep as pathSeparator, extname, resolve as resolvePath, relative, join, } from "node:path";
2
2
  import { pathToFileURL } from "node:url";
3
+ import { getSmashConfig } from "@atomicsmash/cli";
3
4
  import DependencyExtractionWebpackPlugin from "@wordpress/dependency-extraction-webpack-plugin";
4
5
  import browserslistToEsbuild from "browserslist-to-esbuild";
5
6
  import CopyPlugin from "copy-webpack-plugin";
@@ -16,6 +17,7 @@ import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
16
17
  import { BlocksPlugin } from "./BlocksPlugin.js";
17
18
  import { getBlocksAssetsEntryPoints } from "./getBlocksAssetsEntryPoints.js";
18
19
  export async function config(options) {
20
+ const smashConfig = await getSmashConfig();
19
21
  const argv = {
20
22
  watch: false,
21
23
  analyse: false,
@@ -26,8 +28,19 @@ export async function config(options) {
26
28
  const MODE = process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test"
27
29
  ? "development"
28
30
  : "production";
29
- const srcFolder = resolvePath(argv.in);
30
- const distFolder = resolvePath(argv.out);
31
+ const srcFolder = argv.in
32
+ ? resolvePath(argv.in)
33
+ : smashConfig?.themePath
34
+ ? join(smashConfig?.themePath, "src", "blocks")
35
+ : null;
36
+ const distFolder = argv.out
37
+ ? resolvePath(argv.out)
38
+ : smashConfig?.themePath
39
+ ? join(smashConfig?.themePath, smashConfig.assetsOutputFolder, "blocks")
40
+ : null;
41
+ if (!srcFolder || !distFolder) {
42
+ throw new Error("Failed to get the in or out folders for the blocks. Please add a smash.config.ts file to your project with a themeName and a themePath.");
43
+ }
31
44
  // Add optional support for Tailwind if tailwind postcss plugin is installed
32
45
  const tailwindPostCSSPlugin = await import("@tailwindcss/postcss")
33
46
  .then((tailwindPostCSS) => [tailwindPostCSS.default])
@@ -368,6 +381,11 @@ export async function config(options) {
368
381
  };
369
382
  }
370
383
  async function getSassOptions(srcFolder) {
384
+ const smashConfig = await getSmashConfig();
385
+ if (smashConfig) {
386
+ return smashConfig.scssAliases;
387
+ }
388
+ // Legacy fallback.
371
389
  const explorer = cosmiconfig("scssAliases");
372
390
  const config = await explorer
373
391
  .load(resolvePath(process.cwd(), "scssAliases.config.ts"))
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  import type { BlockMetaData } from "@atomicsmash/blocks-helpers";
2
+ import type { ExecException } from "node:child_process";
2
3
  export type BlockJson = BlockMetaData<never, never>;
3
4
  export declare function getBlockJsonScriptFields(blockJson: BlockJson): Partial<Pick<BlockJson, "viewScript" | "script" | "editorScript">> | null;
4
5
  export declare function getBlockJsonStyleFields(blockJson: BlockJson): Partial<Pick<BlockJson, "editorStyle" | "style" | "viewStyle">> | null;
6
+ export declare function execute(command: string, options?: {
7
+ debug: boolean;
8
+ }): Promise<{
9
+ error: ExecException | null;
10
+ stdout: string;
11
+ stderr: string;
12
+ }>;
5
13
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAEpD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,SAAS,6EAW5D;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,0EAW3D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAEpD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,SAAS,6EAW5D;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,0EAW3D;AAED,wBAAsB,OAAO,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAqB;WAGtC,aAAa,GAAG,IAAI;YACnB,MAAM;YACN,MAAM;GAaf"}
package/dist/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { exec } from "node:child_process";
1
2
  export function getBlockJsonScriptFields(blockJson) {
2
3
  const scriptFields = ["viewScript", "script", "editorScript"];
3
4
  let result = null;
@@ -20,3 +21,17 @@ export function getBlockJsonStyleFields(blockJson) {
20
21
  }
21
22
  return result;
22
23
  }
24
+ export async function execute(command, options = { debug: false }) {
25
+ return new Promise((resolve, reject) => {
26
+ exec(command, (error, stdout, stderr) => {
27
+ if (error) {
28
+ if (options.debug) {
29
+ console.error({ error, stdout, stderr });
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- This is preferred in this instance
32
+ reject({ error, stdout, stderr });
33
+ }
34
+ resolve({ error, stdout, stderr });
35
+ });
36
+ });
37
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atomicsmash/compiler",
3
3
  "type": "module",
4
- "version": "1.1.0-beta.3",
4
+ "version": "2.0.0-beta.0",
5
5
  "description": "A universal compiler for all Atomic Smash projects.",
6
6
  "keywords": [
7
7
  "cli",
@@ -79,5 +79,8 @@
79
79
  },
80
80
  "engines": {
81
81
  "node": "^20 || >=22"
82
+ },
83
+ "peerDependencies": {
84
+ "@atomicsmash/cli": "^8.2.0-beta.1"
82
85
  }
83
86
  }