Skip to content

Commit 0abe090

Browse files
feat: support for hosting config (#506)
* feat: support for hosting config Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * feat: source for init Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * feat: review msg Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * chore: shorter Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * feat: released libs Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> --------- Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
1 parent e95c6e6 commit 0abe090

21 files changed

Lines changed: 173 additions & 140 deletions

juno.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ export default defineConfig({
66
development: '<DEV_SATELLITE_ID>',
77
production: '<PROD_SATELLITE_ID>'
88
},
9-
source: 'e2e/fixtures',
10-
precompress: false,
9+
hosting: {
10+
source: 'e2e/fixtures',
11+
precompress: false
12+
},
1113
collections: {
1214
datastore: [
1315
{

package-lock.json

Lines changed: 97 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
"@dfinity/utils": "^4.2.1",
3333
"@icp-sdk/canisters": "^3.5.2",
3434
"@icp-sdk/core": "^5.2.1",
35-
"@junobuild/admin": "^4.3.2",
36-
"@junobuild/cdn": "^2.4.2",
37-
"@junobuild/cli-tools": "^0.13.3",
38-
"@junobuild/config": "^2.15.1",
39-
"@junobuild/config-loader": "^0.4.10",
40-
"@junobuild/core": "^5.3.1",
41-
"@junobuild/functions-tools": "^0.6.3",
42-
"@junobuild/ic-client": "^8.1.2",
43-
"@junobuild/schema": "^1.2.1",
44-
"@junobuild/storage": "^2.4.1",
45-
"@junobuild/utils": "^1.0.2",
35+
"@junobuild/admin": "^4.3.3",
36+
"@junobuild/cdn": "^2.5.0",
37+
"@junobuild/cli-tools": "^0.14.0",
38+
"@junobuild/config": "^3.0.0",
39+
"@junobuild/config-loader": "^0.4.11",
40+
"@junobuild/core": "^5.4.0",
41+
"@junobuild/functions-tools": "^0.6.4",
42+
"@junobuild/ic-client": "^8.1.3",
43+
"@junobuild/schema": "^1.2.2",
44+
"@junobuild/storage": "^2.4.2",
45+
"@junobuild/utils": "^1.0.3",
4646
"chokidar": "^5.0.0",
4747
"conf": "^15.1.0",
4848
"open": "^11.0.0",
@@ -56,7 +56,7 @@
5656
"@eslint/eslintrc": "^3.3.3",
5757
"@eslint/js": "^9.39.2",
5858
"@junobuild/emulator-playwright": "^0.1.1",
59-
"@junobuild/functions": "^0.8.2",
59+
"@junobuild/functions": "^0.8.3",
6060
"@playwright/test": "^1.58.1",
6161
"@types/node": "24.10.9",
6262
"@types/prompts": "^2.4.9",

src/configs/juno.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export const writeJunoConfigPlaceholder = async ({
5555
case 'ts':
5656
case 'js': {
5757
const {
58-
satellite: {source}
58+
satellite: {
59+
hosting: {source}
60+
}
5961
} = config;
6062

6163
const withPredeploy = nonNullish(pm);
@@ -74,7 +76,7 @@ export const writeJunoConfigPlaceholder = async ({
7476
});
7577

7678
let content = template
77-
.replace('<SOURCE>', source ?? DEPLOY_DEFAULT_SOURCE)
79+
.replace('<SOURCE>', source)
7880
.replace('<COMMAND>', pm === 'npm' ? 'npm run' : (pm ?? ''));
7981

8082
if (nonNullish(emulatorConfig)) {

src/services/assets/_deploy/deploy.execute.services.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const executeDeploy = async <
6464
const {satellite, satelliteConfig: satelliteConfigRead} =
6565
await assertConfigAndLoadSatelliteContext();
6666

67+
/** @deprecated */
6768
const precompress =
6869
satelliteConfigRead.precompress ??
6970
(nonNullish(deprecatedGzip)
@@ -77,7 +78,7 @@ const executeDeploy = async <
7778
...(nonNullish(precompress) && {precompress})
7879
};
7980

80-
await cliPreDeploy({config: satelliteConfig});
81+
await cliPreDeploy({config: satelliteConfig.hosting ?? satelliteConfig});
8182

8283
const result = await deployWithMethod<P, R>({
8384
...rest,
@@ -90,7 +91,7 @@ const executeDeploy = async <
9091
process.exit(0);
9192
}
9293

93-
await cliPostDeploy({config: satelliteConfig});
94+
await cliPostDeploy({config: satelliteConfig.hosting ?? satelliteConfig});
9495

9596
return result;
9697
};
@@ -121,7 +122,7 @@ const deployWithMethod = async <
121122
});
122123

123124
const deployParams: DeployParams = {
124-
config: satelliteConfig,
125+
config: satelliteConfig.hosting ?? satelliteConfig,
125126
listAssets: listExistingAssets,
126127
assertSourceDirExists,
127128
assertMemory,
@@ -170,7 +171,7 @@ const assertSourceDirExists = (source: string) => {
170171
console.log(
171172
`${red(
172173
'Cannot proceed deployment.'
173-
)}\nAre you sure the folder containing your built app (the "source" tag in the configuration file for Juno) files is correctly configured, or have you built your app?`
174+
)}\nAre you sure the folder containing your built app files is correctly configured (in your juno.config "hosting > source"), or have you built your app?`
174175
);
175176
process.exit(1);
176177
}

src/services/assets/prune.services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const executePrune = async (params: {dryRun?: boolean; batchSize?: number
4242

4343
const result = await pruneServices({
4444
params: {
45-
config: satelliteConfig,
45+
config: satelliteConfig.hosting ?? satelliteConfig,
4646
listAssets: listExistingAssets,
4747
assertSourceDirExists,
4848
...params

src/services/config/init.services.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ export const initConfigNoneInteractive = async ({
9494
await writeJunoConfigPlaceholder({
9595
...rest,
9696
config: {
97-
satellite: {source}
97+
satellite: {
98+
hosting: {source}
99+
}
98100
},
99101
emulatorConfig
100102
});

src/types/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import type {JunoConfig, OrbiterConfig, SatelliteConfig} from '@junobuild/config';
1+
import type {HostingConfig, JunoConfig, OrbiterConfig, SatelliteConfig} from '@junobuild/config';
22

33
export type JunoConfigWithSatelliteId = Omit<JunoConfig, 'satellite' | 'orbiter'> & {
44
satellite: Omit<SatelliteConfig, 'id' | 'satellitesIds'> & Required<Pick<SatelliteConfig, 'id'>>;
55
orbiter?: Omit<OrbiterConfig, 'orbiterId'>;
66
};
77

88
export type JunoConfigWithPlaceholder = Omit<JunoConfig, 'satellite' | 'orbiter'> & {
9-
satellite: Pick<SatelliteConfig, 'source'>;
9+
satellite: {
10+
hosting: Pick<HostingConfig, 'source'>;
11+
};
1012
};

src/types/deploy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {OnUploadProgress} from '@junobuild/storage';
99
import type {SatelliteParametersWithId} from './satellite';
1010

1111
export interface DeployOptions {
12+
/** @deprecated */
1213
deprecatedGzip?: string;
1314
uploadBatchSize: number | undefined;
1415
}

templates/init/juno.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export default defineConfig({
77
development: '<DEV_SATELLITE_ID>',
88
production: '<PROD_SATELLITE_ID>'
99
},
10-
source: '<SOURCE>'
10+
hosting: {
11+
source: '<SOURCE>'
12+
}
1113
},
1214
orbiter: {
1315
id: '<ORBITER_ID>'

0 commit comments

Comments
 (0)