Skip to content

Commit efbd3eb

Browse files
fix: bump new release (#2409)
Ran prettier
1 parent 475d5e1 commit efbd3eb

File tree

6 files changed

+155
-155
lines changed

6 files changed

+155
-155
lines changed

packages/contentful--app-scripts/src/bin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,5 @@ async function runCommand(command: Command, options?: any) {
161161
})().catch((e) => {
162162
console.error(e);
163163
// eslint-disable-next-line no-process-exit
164-
process.exit(1)
164+
process.exit(1);
165165
});

packages/contentful--app-scripts/src/create-type-safe-locations.test.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
11
import assert from 'assert';
2-
import { createTypeSafeLocations } from "./create-type-safe-locations"; // Update with actual file path
3-
import { LocationsSettings } from "./types";
2+
import { createTypeSafeLocations } from './create-type-safe-locations'; // Update with actual file path
3+
import { LocationsSettings } from './types';
44

5-
describe("createTypeSafeLocations", () => {
6-
it("should return mapped locations with fieldTypes for entry-field", () => {
5+
describe('createTypeSafeLocations', () => {
6+
it('should return mapped locations with fieldTypes for entry-field', () => {
77
const settings: LocationsSettings = {
8-
locations: ["entry-field"],
9-
fields: [{ type: "Text" }, { type: "Number" }],
8+
locations: ['entry-field'],
9+
fields: [{ type: 'Text' }, { type: 'Number' }],
1010
};
1111

1212
const result = createTypeSafeLocations(settings);
1313

1414
assert.deepEqual(result, [
1515
{
16-
location: "entry-field",
17-
fieldTypes: [{ type: "Text" }, { type: "Number" }],
16+
location: 'entry-field',
17+
fieldTypes: [{ type: 'Text' }, { type: 'Number' }],
1818
},
1919
]);
2020
});
2121

22-
it("should return mapped locations with navigationItem for page", () => {
22+
it('should return mapped locations with navigationItem for page', () => {
2323
const settings: LocationsSettings = {
24-
locations: ["page"],
24+
locations: ['page'],
2525
pageNav: true,
26-
pageNavLinkName: "Home",
27-
pageNavLinkPath: "/home",
26+
pageNavLinkName: 'Home',
27+
pageNavLinkPath: '/home',
2828
};
2929

3030
const result = createTypeSafeLocations(settings);
3131

3232
assert.deepEqual(result, [
3333
{
34-
location: "page",
34+
location: 'page',
3535
navigationItem: {
36-
name: "Home",
37-
path: "/home",
36+
name: 'Home',
37+
path: '/home',
3838
},
3939
},
4040
]);
4141
});
4242

43-
it("should return mapped locations without navigationItem if pageNav is false", () => {
43+
it('should return mapped locations without navigationItem if pageNav is false', () => {
4444
const settings: LocationsSettings = {
45-
locations: ["page"],
45+
locations: ['page'],
4646
pageNav: false,
4747
};
4848

4949
const result = createTypeSafeLocations(settings);
5050

5151
assert.deepEqual(result, [
5252
{
53-
location: "page",
53+
location: 'page',
5454
},
5555
]);
5656
});
5757

58-
it("should return an array of objects with just location for unknown locations", () => {
58+
it('should return an array of objects with just location for unknown locations', () => {
5959
const settings: LocationsSettings = {
60-
locations: ["app-config"],
60+
locations: ['app-config'],
6161
};
6262

6363
const result = createTypeSafeLocations(settings);
6464

6565
assert.deepEqual(result, [
6666
{
67-
location: "app-config",
67+
location: 'app-config',
6868
},
6969
]);
7070
});
7171

72-
it("should return an empty array if locations array is empty", () => {
72+
it('should return an empty array if locations array is empty', () => {
7373
const settings: LocationsSettings = {
7474
locations: [],
7575
};
Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
1-
import { LocationsSettings } from "./types";
1+
import { LocationsSettings } from './types';
22

3-
export function createTypeSafeLocations(settings: LocationsSettings){
4-
const {
5-
locations,
6-
fields,
7-
pageNav,
8-
pageNavLinkName,
9-
pageNavLinkPath
10-
} = settings
11-
return locations.map((location) => {
12-
if (location === 'entry-field') {
13-
return {
14-
location,
15-
fieldTypes: fields || [],
16-
};
17-
}
3+
export function createTypeSafeLocations(settings: LocationsSettings) {
4+
const { locations, fields, pageNav, pageNavLinkName, pageNavLinkPath } = settings;
5+
return locations.map((location) => {
6+
if (location === 'entry-field') {
7+
return {
8+
location,
9+
fieldTypes: fields || [],
10+
};
11+
}
1812

19-
if (location === 'page') {
20-
return {
21-
location,
22-
...(pageNav
23-
? {
24-
navigationItem: {
25-
name: pageNavLinkName,
26-
path: pageNavLinkPath,
27-
},
28-
}
29-
: {}),
30-
};
31-
}
13+
if (location === 'page') {
14+
return {
15+
location,
16+
...(pageNav
17+
? {
18+
navigationItem: {
19+
name: pageNavLinkName,
20+
path: pageNavLinkPath,
21+
},
22+
}
23+
: {}),
24+
};
25+
}
3226

33-
return {
34-
location,
35-
};
36-
});
37-
}
27+
return {
28+
location,
29+
};
30+
});
31+
}

packages/contentful--app-scripts/src/definition-api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ export async function getDefinitionById(
5858
return {
5959
name: definition.name,
6060
value: definition.sys.id,
61-
locations: definition.locations ? definition.locations.map((location) => location.location) : [],
61+
locations: definition.locations
62+
? definition.locations.map((location) => location.location)
63+
: [],
6264
};
6365
} catch (err: any) {
6466
return throwError(
Lines changed: 94 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,106 @@
1-
import { LocationsSettings } from "./types";
1+
import { LocationsSettings } from './types';
22

33
export const selectLocationsPrompt = {
4-
name: 'locations',
5-
message: `Select where your app can be rendered:`,
6-
type: 'checkbox',
7-
choices: [
8-
{ name: 'App configuration screen ', value: 'app-config' },
9-
{ name: 'Entry field', value: 'entry-field' },
10-
{ name: 'Entry sidebar', value: 'entry-sidebar' },
11-
{ name: 'Entry editor', value: 'entry-editor' },
12-
{ name: 'Page', value: 'page' },
13-
{ name: 'Home', value: 'home' },
14-
],
15-
}
4+
name: 'locations',
5+
message: `Select where your app can be rendered:`,
6+
type: 'checkbox',
7+
choices: [
8+
{ name: 'App configuration screen ', value: 'app-config' },
9+
{ name: 'Entry field', value: 'entry-field' },
10+
{ name: 'Entry sidebar', value: 'entry-sidebar' },
11+
{ name: 'Entry editor', value: 'entry-editor' },
12+
{ name: 'Page', value: 'page' },
13+
{ name: 'Home', value: 'home' },
14+
],
15+
};
1616

1717
export const selectFieldsPrompt = {
18-
name: 'fields',
19-
message: 'Select the field types the app can be rendered:',
20-
type: 'checkbox',
21-
choices: [
22-
{ name: 'Short text', value: { type: 'Symbol' } },
23-
{ name: 'Short text, list', value: { type: 'Array', items: { type: 'Symbol' } } },
24-
{ name: 'Long text', value: { type: 'Text' } },
25-
{ name: 'Rich text', value: { type: 'RichText' } },
26-
{ name: 'Number, integer', value: { type: 'Integer' } },
27-
{ name: 'Number, decimal', value: { type: 'Number' } },
28-
{ name: 'Date and time', value: { type: 'Date' } },
29-
{ name: 'Location', value: { type: 'Location' } },
30-
{ name: 'Boolean', value: { type: 'Boolean' } },
31-
{ name: 'JSON object', value: { type: 'Object' } },
32-
{ name: 'Entry reference', value: { type: 'Link', linkType: 'Entry' } },
33-
{
34-
name: 'Entry reference, list',
35-
value: {
36-
type: 'Array',
37-
items: {
38-
type: 'Link',
39-
linkType: 'Entry',
40-
},
18+
name: 'fields',
19+
message: 'Select the field types the app can be rendered:',
20+
type: 'checkbox',
21+
choices: [
22+
{ name: 'Short text', value: { type: 'Symbol' } },
23+
{ name: 'Short text, list', value: { type: 'Array', items: { type: 'Symbol' } } },
24+
{ name: 'Long text', value: { type: 'Text' } },
25+
{ name: 'Rich text', value: { type: 'RichText' } },
26+
{ name: 'Number, integer', value: { type: 'Integer' } },
27+
{ name: 'Number, decimal', value: { type: 'Number' } },
28+
{ name: 'Date and time', value: { type: 'Date' } },
29+
{ name: 'Location', value: { type: 'Location' } },
30+
{ name: 'Boolean', value: { type: 'Boolean' } },
31+
{ name: 'JSON object', value: { type: 'Object' } },
32+
{ name: 'Entry reference', value: { type: 'Link', linkType: 'Entry' } },
33+
{
34+
name: 'Entry reference, list',
35+
value: {
36+
type: 'Array',
37+
items: {
38+
type: 'Link',
39+
linkType: 'Entry',
4140
},
42-
},
43-
{ name: 'Media reference', value: { type: 'Link', linkType: 'Asset' } },
44-
{
45-
name: 'Media reference, list',
46-
value: { type: 'Array', items: { type: 'Link', linkType: 'Asset' } },
47-
},
48-
],
49-
when(answers: LocationsSettings) {
50-
return answers.locations.includes('entry-field');
41+
},
5142
},
52-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
53-
validate(input: any) {
54-
if (input.length < 1) {
55-
return 'You must choose at least one field type.';
56-
}
57-
return true;
43+
{ name: 'Media reference', value: { type: 'Link', linkType: 'Asset' } },
44+
{
45+
name: 'Media reference, list',
46+
value: { type: 'Array', items: { type: 'Link', linkType: 'Asset' } },
5847
},
59-
}
48+
],
49+
when(answers: LocationsSettings) {
50+
return answers.locations.includes('entry-field');
51+
},
52+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
53+
validate(input: any) {
54+
if (input.length < 1) {
55+
return 'You must choose at least one field type.';
56+
}
57+
return true;
58+
},
59+
};
6060

6161
export const pageNavPrompt = {
62-
name: 'pageNav',
63-
message: 'Page location: Would you like your page location to render in the main navigation?',
64-
type: 'confirm',
65-
default: false,
66-
when(answers: LocationsSettings) {
67-
return answers.locations.includes('page');
68-
},
69-
}
62+
name: 'pageNav',
63+
message: 'Page location: Would you like your page location to render in the main navigation?',
64+
type: 'confirm',
65+
default: false,
66+
when(answers: LocationsSettings) {
67+
return answers.locations.includes('page');
68+
},
69+
};
7070

71-
export const pageNavLinkNamePrompt = {
72-
name: 'pageNavLinkName',
73-
message: 'Page location: Provide a name for the link in the main navigation:',
74-
when(answers: LocationsSettings) {
75-
return answers.locations.includes('page') && answers.pageNav;
76-
},
77-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
78-
validate(input: any) {
79-
if (input.length < 1 || input.length > 40) {
80-
return 'Size must be at least 1 and at most 40';
81-
}
82-
return true;
83-
},
84-
}
71+
export const pageNavLinkNamePrompt = {
72+
name: 'pageNavLinkName',
73+
message: 'Page location: Provide a name for the link in the main navigation:',
74+
when(answers: LocationsSettings) {
75+
return answers.locations.includes('page') && answers.pageNav;
76+
},
77+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
78+
validate(input: any) {
79+
if (input.length < 1 || input.length > 40) {
80+
return 'Size must be at least 1 and at most 40';
81+
}
82+
return true;
83+
},
84+
};
8585

8686
export const pageNavLinkPathPrompt = {
87-
name: 'pageNavLinkPath',
88-
message:
89-
'Page location: Provide a path which starts with / and does not contain empty space:',
90-
default: '/',
91-
when(answers: LocationsSettings) {
92-
return answers.locations.includes('page') && answers.pageNav;
93-
},
94-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
95-
validate(input: any) {
96-
if (input.length > 512) {
97-
return 'Maximum 512 characters';
98-
}
99-
if (input.includes(' ')) {
100-
return 'Path cannot contain empty space';
101-
}
102-
if (!input.startsWith('/')) {
103-
return 'Path must start with /';
104-
}
105-
return true;
106-
},
107-
}
87+
name: 'pageNavLinkPath',
88+
message: 'Page location: Provide a path which starts with / and does not contain empty space:',
89+
default: '/',
90+
when(answers: LocationsSettings) {
91+
return answers.locations.includes('page') && answers.pageNav;
92+
},
93+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
94+
validate(input: any) {
95+
if (input.length > 512) {
96+
return 'Maximum 512 characters';
97+
}
98+
if (input.includes(' ')) {
99+
return 'Path cannot contain empty space';
100+
}
101+
if (!input.startsWith('/')) {
102+
return 'Path must start with /';
103+
}
104+
return true;
105+
},
106+
};

0 commit comments

Comments
 (0)