@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.25 → 3.5.0-ultramodern.26

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.
@@ -449,6 +449,16 @@ const normalizeCloudflareArtifact = (artifact, index)=>{
449
449
  };
450
450
  };
451
451
  const getCloudflareArtifacts = (modernConfig)=>(modernConfig.deploy?.worker?.artifacts ?? []).map(normalizeCloudflareArtifact);
452
+ const normalizeCloudflarePublicAsset = (asset, index)=>{
453
+ const from = normalizeRelativePath(asset.from, `deploy.worker.publicAssets[${index}].from`, 'app root');
454
+ const to = normalizeRelativePath(asset.to, `deploy.worker.publicAssets[${index}].to`, 'Cloudflare public output');
455
+ return {
456
+ from,
457
+ to,
458
+ index
459
+ };
460
+ };
461
+ const getCloudflarePublicAssets = (modernConfig)=>(modernConfig.deploy?.worker?.publicAssets ?? []).map(normalizeCloudflarePublicAsset);
452
462
  const copyCloudflareArtifacts = async (appDirectory, outputDirectory, artifacts)=>{
453
463
  for (const artifact of artifacts){
454
464
  const sourcePath = external_node_path_default().join(appDirectory, artifact.from);
@@ -456,6 +466,13 @@ const copyCloudflareArtifacts = async (appDirectory, outputDirectory, artifacts)
456
466
  await utils_namespaceObject.fs.copy(sourcePath, external_node_path_default().join(outputDirectory, artifact.to));
457
467
  }
458
468
  };
469
+ const copyCloudflarePublicAssets = async (appDirectory, publicDirectory, publicAssets)=>{
470
+ for (const asset of publicAssets){
471
+ const sourcePath = external_node_path_default().join(appDirectory, asset.from);
472
+ if (!await utils_namespaceObject.fs.pathExists(sourcePath)) throw new Error(`deploy.worker.publicAssets[${asset.index}].from does not exist: ${asset.from}`);
473
+ await utils_namespaceObject.fs.copy(sourcePath, external_node_path_default().join(publicDirectory, asset.to));
474
+ }
475
+ };
459
476
  const copyCloudflareD1Migrations = async (appDirectory, outputDirectory, modernConfig)=>{
460
477
  for (const [index, database] of (modernConfig.deploy?.worker?.d1Databases ?? []).entries()){
461
478
  if (!database.migrationsDir) continue;
@@ -610,6 +627,7 @@ const createCloudflarePreset = ({ appContext, modernConfig })=>{
610
627
  });
611
628
  }
612
629
  await copyCloudflareArtifacts(appDirectory, outputDirectory, cloudflareArtifacts);
630
+ await copyCloudflarePublicAssets(appDirectory, publicDirectory, getCloudflarePublicAssets(modernConfig));
613
631
  await copyCloudflareD1Migrations(appDirectory, outputDirectory, modernConfig);
614
632
  await utils_namespaceObject.fs.writeJSON(wranglerConfigPath, createWranglerConfig(appDirectory, modernConfig), {
615
633
  spaces: 2
@@ -407,6 +407,16 @@ const normalizeCloudflareArtifact = (artifact, index)=>{
407
407
  };
408
408
  };
409
409
  const getCloudflareArtifacts = (modernConfig)=>(modernConfig.deploy?.worker?.artifacts ?? []).map(normalizeCloudflareArtifact);
410
+ const normalizeCloudflarePublicAsset = (asset, index)=>{
411
+ const from = normalizeRelativePath(asset.from, `deploy.worker.publicAssets[${index}].from`, 'app root');
412
+ const to = normalizeRelativePath(asset.to, `deploy.worker.publicAssets[${index}].to`, 'Cloudflare public output');
413
+ return {
414
+ from,
415
+ to,
416
+ index
417
+ };
418
+ };
419
+ const getCloudflarePublicAssets = (modernConfig)=>(modernConfig.deploy?.worker?.publicAssets ?? []).map(normalizeCloudflarePublicAsset);
410
420
  const copyCloudflareArtifacts = async (appDirectory, outputDirectory, artifacts)=>{
411
421
  for (const artifact of artifacts){
412
422
  const sourcePath = node_path.join(appDirectory, artifact.from);
@@ -414,6 +424,13 @@ const copyCloudflareArtifacts = async (appDirectory, outputDirectory, artifacts)
414
424
  await fs.copy(sourcePath, node_path.join(outputDirectory, artifact.to));
415
425
  }
416
426
  };
427
+ const copyCloudflarePublicAssets = async (appDirectory, publicDirectory, publicAssets)=>{
428
+ for (const asset of publicAssets){
429
+ const sourcePath = node_path.join(appDirectory, asset.from);
430
+ if (!await fs.pathExists(sourcePath)) throw new Error(`deploy.worker.publicAssets[${asset.index}].from does not exist: ${asset.from}`);
431
+ await fs.copy(sourcePath, node_path.join(publicDirectory, asset.to));
432
+ }
433
+ };
417
434
  const copyCloudflareD1Migrations = async (appDirectory, outputDirectory, modernConfig)=>{
418
435
  for (const [index, database] of (modernConfig.deploy?.worker?.d1Databases ?? []).entries()){
419
436
  if (!database.migrationsDir) continue;
@@ -568,6 +585,7 @@ const createCloudflarePreset = ({ appContext, modernConfig })=>{
568
585
  });
569
586
  }
570
587
  await copyCloudflareArtifacts(appDirectory, outputDirectory, cloudflareArtifacts);
588
+ await copyCloudflarePublicAssets(appDirectory, publicDirectory, getCloudflarePublicAssets(modernConfig));
571
589
  await copyCloudflareD1Migrations(appDirectory, outputDirectory, modernConfig);
572
590
  await fs.writeJSON(wranglerConfigPath, createWranglerConfig(appDirectory, modernConfig), {
573
591
  spaces: 2
@@ -408,6 +408,16 @@ const normalizeCloudflareArtifact = (artifact, index)=>{
408
408
  };
409
409
  };
410
410
  const getCloudflareArtifacts = (modernConfig)=>(modernConfig.deploy?.worker?.artifacts ?? []).map(normalizeCloudflareArtifact);
411
+ const normalizeCloudflarePublicAsset = (asset, index)=>{
412
+ const from = normalizeRelativePath(asset.from, `deploy.worker.publicAssets[${index}].from`, 'app root');
413
+ const to = normalizeRelativePath(asset.to, `deploy.worker.publicAssets[${index}].to`, 'Cloudflare public output');
414
+ return {
415
+ from,
416
+ to,
417
+ index
418
+ };
419
+ };
420
+ const getCloudflarePublicAssets = (modernConfig)=>(modernConfig.deploy?.worker?.publicAssets ?? []).map(normalizeCloudflarePublicAsset);
411
421
  const copyCloudflareArtifacts = async (appDirectory, outputDirectory, artifacts)=>{
412
422
  for (const artifact of artifacts){
413
423
  const sourcePath = node_path.join(appDirectory, artifact.from);
@@ -415,6 +425,13 @@ const copyCloudflareArtifacts = async (appDirectory, outputDirectory, artifacts)
415
425
  await fs.copy(sourcePath, node_path.join(outputDirectory, artifact.to));
416
426
  }
417
427
  };
428
+ const copyCloudflarePublicAssets = async (appDirectory, publicDirectory, publicAssets)=>{
429
+ for (const asset of publicAssets){
430
+ const sourcePath = node_path.join(appDirectory, asset.from);
431
+ if (!await fs.pathExists(sourcePath)) throw new Error(`deploy.worker.publicAssets[${asset.index}].from does not exist: ${asset.from}`);
432
+ await fs.copy(sourcePath, node_path.join(publicDirectory, asset.to));
433
+ }
434
+ };
418
435
  const copyCloudflareD1Migrations = async (appDirectory, outputDirectory, modernConfig)=>{
419
436
  for (const [index, database] of (modernConfig.deploy?.worker?.d1Databases ?? []).entries()){
420
437
  if (!database.migrationsDir) continue;
@@ -569,6 +586,7 @@ const createCloudflarePreset = ({ appContext, modernConfig })=>{
569
586
  });
570
587
  }
571
588
  await copyCloudflareArtifacts(appDirectory, outputDirectory, cloudflareArtifacts);
589
+ await copyCloudflarePublicAssets(appDirectory, publicDirectory, getCloudflarePublicAssets(modernConfig));
572
590
  await copyCloudflareD1Migrations(appDirectory, outputDirectory, modernConfig);
573
591
  await fs.writeJSON(wranglerConfigPath, createWranglerConfig(appDirectory, modernConfig), {
574
592
  spaces: 2
@@ -14,6 +14,17 @@ export interface CloudflareWorkerArtifactConfig {
14
14
  */
15
15
  to: string;
16
16
  }
17
+ export interface CloudflareWorkerPublicAssetConfig {
18
+ /**
19
+ * Source file or directory, relative to the app root, to copy into
20
+ * Cloudflare Worker Static Assets.
21
+ */
22
+ from: string;
23
+ /**
24
+ * Destination path relative to `.output/public`.
25
+ */
26
+ to: string;
27
+ }
17
28
  export interface CloudflareWorkerD1DatabaseConfig {
18
29
  /**
19
30
  * Worker binding name, for example `DB`.
@@ -1,5 +1,5 @@
1
- import type { CloudflareWorkerArtifactConfig, CloudflareWorkerD1DatabaseConfig, CloudflareWorkerSecurityConfig, DeployTarget, JsonValue } from './cloudflareDeploy';
2
- export type { CloudflareWorkerArtifactConfig, CloudflareWorkerD1DatabaseConfig, CloudflareWorkerSecurityConfig, CloudflareWorkerSecurityCorsConfig, CloudflareWorkerSecurityCspConfig, CloudflareWorkerSecurityCspMode, CloudflareWorkerSecurityNoindexConfig, DeployTarget, JsonValue, } from './cloudflareDeploy';
1
+ import type { CloudflareWorkerArtifactConfig, CloudflareWorkerD1DatabaseConfig, CloudflareWorkerPublicAssetConfig, CloudflareWorkerSecurityConfig, DeployTarget, JsonValue } from './cloudflareDeploy';
2
+ export type { CloudflareWorkerArtifactConfig, CloudflareWorkerD1DatabaseConfig, CloudflareWorkerPublicAssetConfig, CloudflareWorkerSecurityConfig, CloudflareWorkerSecurityCorsConfig, CloudflareWorkerSecurityCspConfig, CloudflareWorkerSecurityCspMode, CloudflareWorkerSecurityNoindexConfig, DeployTarget, JsonValue, } from './cloudflareDeploy';
3
3
  export interface MicroFrontend {
4
4
  /**
5
5
  * Specifies whether to enable the HTML entry.
@@ -47,6 +47,11 @@ export interface DeployUserConfig {
47
47
  * Use this for provider resources such as migrations or generated config.
48
48
  */
49
49
  artifacts?: CloudflareWorkerArtifactConfig[];
50
+ /**
51
+ * Additional app-root files or directories to serve as Cloudflare Worker
52
+ * Static Assets under `.output/public`.
53
+ */
54
+ publicAssets?: CloudflareWorkerPublicAssetConfig[];
50
55
  /**
51
56
  * First-class Cloudflare D1 bindings. Modern.js writes these to
52
57
  * `wrangler.json` as `d1_databases` and stages configured migration
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.5.0-ultramodern.25",
20
+ "version": "3.5.0-ultramodern.26",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -90,16 +90,16 @@
90
90
  "ndepe": "^0.1.13",
91
91
  "pkg-types": "^2.3.1",
92
92
  "std-env": "4.1.0",
93
- "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.5.0-ultramodern.25",
94
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.25",
95
- "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.5.0-ultramodern.25",
96
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.5.0-ultramodern.25",
97
- "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.5.0-ultramodern.25",
98
- "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.5.0-ultramodern.25",
99
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.25",
100
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.25",
101
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.5.0-ultramodern.25",
102
- "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.5.0-ultramodern.25"
93
+ "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.5.0-ultramodern.26",
94
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.5.0-ultramodern.26",
95
+ "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.5.0-ultramodern.26",
96
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.26",
97
+ "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.5.0-ultramodern.26",
98
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.5.0-ultramodern.26",
99
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.26",
100
+ "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.5.0-ultramodern.26",
101
+ "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.5.0-ultramodern.26",
102
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.26"
103
103
  },
104
104
  "devDependencies": {
105
105
  "@rslib/core": "0.23.1",