Skip to content

Commit 33271d9

Browse files
arthurdennerCompuIves
authored andcommitted
fix(deployments): use correct property to compare filename (codesandbox#3024)
* fix(deployments): use correct property to compare filename * chore(deployments): add types to ZEIT Now's effects file
1 parent 3968a6d commit 33271d9

File tree

1 file changed

+29
-4
lines changed
  • packages/app/src/app/overmind/effects

1 file changed

+29
-4
lines changed

packages/app/src/app/overmind/effects/zeit.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ type Options = {
1212
getToken(): string;
1313
};
1414

15+
interface Object {
16+
[key: string]: string;
17+
}
18+
19+
interface ApiData {
20+
builds: Object[];
21+
config?: Object;
22+
deploymentType?: string;
23+
env?: Object;
24+
files: File[];
25+
forceNew?: boolean;
26+
name: string;
27+
public: boolean;
28+
regions: string[];
29+
routes: Object[];
30+
scope?: string;
31+
version: number;
32+
}
33+
34+
interface File {
35+
data: string;
36+
encoding?: string;
37+
file: string;
38+
}
39+
1540
export default (() => {
1641
let _options: Options;
1742

@@ -133,7 +158,7 @@ export default (() => {
133158
async function getApiData(contents: any, sandbox: Sandbox) {
134159
const template = getTemplate(sandbox.template);
135160

136-
let apiData: any = {
161+
let apiData: Partial<ApiData> = {
137162
files: [],
138163
};
139164
let packageJSON: any = {};
@@ -159,7 +184,7 @@ async function getApiData(contents: any, sandbox: Sandbox) {
159184
nowJSON = packageJSON.now;
160185
}
161186

162-
const nowDefaults: any = {
187+
const nowDefaults: Pick<ApiData, 'name' | 'public'> = {
163188
name: `csb-${sandbox.id}`,
164189
public: true,
165190
};
@@ -174,7 +199,7 @@ async function getApiData(contents: any, sandbox: Sandbox) {
174199
packageJSON.name = nowJSON.name || nowDefaults.name;
175200

176201
apiData.name = nowJSON.name || nowDefaults.name;
177-
apiData.deploymentType = nowJSON.type || nowDefaults.type;
202+
apiData.deploymentType = nowJSON.type;
178203
apiData.public = nowJSON.public || nowDefaults.public;
179204

180205
// if now v2 we need to tell now the version, builds and routes
@@ -217,7 +242,7 @@ async function getApiData(contents: any, sandbox: Sandbox) {
217242
// if person added some files but no package.json
218243
if (
219244
filePath === 'package.json' &&
220-
!apiData.files.find(f => f.name === 'package.json')
245+
!apiData.files.find(f => f.file === 'package.json')
221246
) {
222247
apiData.files.push({
223248
file: 'package.json',

0 commit comments

Comments
 (0)