Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Dependency directories
node_modules/
jspm_packages/

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

dist
.vercel
.DS_Store
*-temp.json

# Files and folders that start with a dot
.*

# yaml files
*.yaml

# Markdown files
*.md
18 changes: 18 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"endOfLine": "crlf",
"experimentalTernaries": true,
"jsxSingleQuote": true,
"printWidth": 120,
"proseWrap": "always",
"quoteProps": "as-needed",
"rangeStart": 0,
"requirePragma": false,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
2 changes: 1 addition & 1 deletion __test__/test-website/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextConfig } from "next";
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
/* config options here */
Expand Down
7 changes: 2 additions & 5 deletions __test__/test-website/src/app/en/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ import {
ctString,
ctWithCollision,
} from '@/components/with-repeated-properties';
import {
initContentTypeRegistry,
initDisplayTemplateRegistry,
} from '@optimizely/cms-sdk';
import { initContentTypeRegistry, initDisplayTemplateRegistry } from '@optimizely/cms-sdk';
import { initReactComponentRegistry } from '@optimizely/cms-sdk/react/server';

initContentTypeRegistry([
Expand Down Expand Up @@ -103,7 +100,7 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang="en">
<html lang='en'>
<body>{children}</body>
</html>
);
Expand Down
12 changes: 4 additions & 8 deletions __test__/test-website/src/app/missing-content-types/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
}
};

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<html lang='en'>
<body>{children}</body>
</html>
)
);
}
6 changes: 1 addition & 5 deletions __test__/test-website/src/app/missing-content-types/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ct4,
ct5,
notSynced,
} from '@/components/missing-content-types/not-synced';
import { ct4, ct5, notSynced } from '@/components/missing-content-types/not-synced';
import { GraphClient, initContentTypeRegistry } from '@optimizely/cms-sdk';
import React from 'react';

Expand Down
3 changes: 1 addition & 2 deletions __test__/test-website/src/app/multi-host/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export default async function Page({ params }: Props) {
const client = new GraphClient(process.env.OPTIMIZELY_GRAPH_SINGLE_KEY!, {
graphUrl: process.env.OPTIMIZELY_GRAPH_GATEWAY,
});
const host =
process.env.NEXTJS_HOST ?? `https://localhost:${process.env.PORT ?? 3000}`;
const host = process.env.NEXTJS_HOST ?? `https://localhost:${process.env.PORT ?? 3000}`;

const content = await client.getContentByPath(`/${slug.join('/')}/`, {
host,
Expand Down
12 changes: 4 additions & 8 deletions __test__/test-website/src/app/multi-host/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
}
};

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<html lang='en'>
<body>{children}</body>
</html>
)
);
}
8 changes: 3 additions & 5 deletions __test__/test-website/src/app/preview/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export default async function Page({ searchParams }: Props) {
const response = await client
.getPreviewContent(
// TODO: check types in runtime properly
(await searchParams) as PreviewParams
(await searchParams) as PreviewParams,
)
.catch((err) => {
.catch(err => {
console.log(err.errors);
console.log(err.request);

Expand All @@ -29,9 +29,7 @@ export default async function Page({ searchParams }: Props) {

return (
<>
<Script
src={`${process.env.OPTIMIZELY_CMS_URL}/util/javascript/communicationinjector.js`}
></Script>
<Script src={`${process.env.OPTIMIZELY_CMS_URL}/util/javascript/communicationinjector.js`}></Script>
<PreviewComponent />
<OptimizelyComponent content={response} />
</>
Expand Down
2 changes: 1 addition & 1 deletion __test__/test-website/src/app/related/[...slug]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang="en">
<html lang='en'>
<body>{children}</body>
</html>
);
Expand Down
4 changes: 2 additions & 2 deletions __test__/test-website/src/app/related/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export default async function Page({ params }: Props) {
<h1>Links from this page</h1>
<h2>Children</h2>
<ul>
{children?.map((l) => (
{children?.map(l => (
<li key={l._metadata?.key}>
{l?._metadata?.displayName} ({l?._metadata?.url?.default})
</li>
))}
</ul>
<h2>Ancestors (breadcrumbs)</h2>
<ol>
{ancestors?.map((l) => (
{ancestors?.map(l => (
<li key={l._metadata?.key}>
{l?._metadata?.displayName} ({l?._metadata?.url?.default})
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { contentType } from '@optimizely/cms-sdk';
export const notInRegistry = contentType({
baseType: '_component',
key: 'test_c6',
displayName:
"test_c6: This content type is not added in the 'initContentTypeRegistry')",
displayName: "test_c6: This content type is not added in the 'initContentTypeRegistry')",
properties: {
p1: { type: 'string' },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { contentType } from '@optimizely/cms-sdk';
// This content type IS synced to the CMS.
export const ct4 = contentType({
baseType: '_page',
displayName:
'test_c4: Refer to a content type that is not synced to graph (missing in the CMS)',
displayName: 'test_c4: Refer to a content type that is not synced to graph (missing in the CMS)',
key: 'test_c4_refs_missing',

properties: {
Expand Down
13 changes: 2 additions & 11 deletions __test__/test-website/src/components/with-display-templates.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
BlankSectionContentType,
contentType,
displayTemplate,
ContentProps,
} from '@optimizely/cms-sdk';
import { BlankSectionContentType, contentType, displayTemplate, ContentProps } from '@optimizely/cms-sdk';
import {
OptimizelyComposition,
OptimizelyGridSection,
Expand Down Expand Up @@ -221,11 +216,7 @@ export function BlankSection2({ content }: BlankSectionProps) {
return (
<>
<h2>This is BlankSection2 {content.key}</h2>
<OptimizelyGridSection
nodes={content.nodes}
row={Row2}
column={Column2}
/>
<OptimizelyGridSection nodes={content.nodes} row={Row2} column={Column2} />
</>
);
}
20 changes: 2 additions & 18 deletions __test__/test-website/src/components/with-repeated-properties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,13 @@ export const ctWithCollision = contentType({
properties: {
collision: {
type: 'content',
allowedTypes: [
ctString,
ctBoolean,
ctInteger,
ctRich,
ctLink,
ctContentReference,
ctArray,
],
allowedTypes: [ctString, ctBoolean, ctInteger, ctRich, ctLink, ctContentReference, ctArray],
},
p2: {
type: 'array',
items: {
type: 'content',
allowedTypes: [
ctString,
ctBoolean,
ctInteger,
ctRich,
ctLink,
ctContentReference,
ctArray,
],
allowedTypes: [ctString, ctBoolean, ctInteger, ctRich, ctLink, ctContentReference, ctArray],
},
},
},
Expand Down
22 changes: 4 additions & 18 deletions __test__/test-website/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -23,19 +19,9 @@
}
],
"paths": {
"@/*": [
"./src/*"
]
"@/*": ["./src/*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", ".next/dev/types/**/*.ts"],
"exclude": ["node_modules"]
}
5 changes: 1 addition & 4 deletions __test__/test-website/with-display-templates.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { buildConfig } from '@optimizely/cms-sdk';

export default buildConfig({
components: [
'./src/components/with-display-templates.tsx',
'./src/components/with-repeated-properties.tsx',
],
components: ['./src/components/with-display-templates.tsx', './src/components/with-repeated-properties.tsx'],
});
19 changes: 14 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,32 @@
"build:samples": "pnpm --filter \"./samples/**\" build",
"clean:all": "pnpm -r clean",
"test": "echo \"Error: no test specified\" && exit 1",
"publish:all": "pnpm --filter \"./packages/**\" publish --access public --no-git-checks"
"publish:all": "pnpm --filter \"./packages/**\" publish --access public --no-git-checks",
"update-hooks": "pnpm simple-git-hooks"
},
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
"devDependencies": {
"lerna": "^8.2.2"
"lerna": "^8.2.2",
"prettier": "3.8.3",
"pretty-quick": "^4.2.2",
"simple-git-hooks": "^2.13.1"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild",
"lightningcss"
],
"supportedArchitectures": {
"os": ["current"],
"cpu": ["current"]
"os": [
"current"
],
"cpu": [
"current"
]
},
"overrides": {
"@redocly/ajv": "npm:ajv@^8.18.0"
}
}
}
}

11 changes: 4 additions & 7 deletions packages/optimizely-cms-cli/src/baseCommand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Command, Flags, Interfaces, Errors } from '@oclif/core';
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<
(typeof BaseCommand)['baseFlags'] & T['flags']
>;
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;

/**
Expand All @@ -20,14 +18,14 @@ function handleFlagsError(err: any) {

if (requiredFlags.length > 0) {
const givenFlags = Object.keys(userFlags);
const missingFlags = requiredFlags.filter((f) => !givenFlags.includes(f));
const missingFlags = requiredFlags.filter(f => !givenFlags.includes(f));

if (missingFlags.length === 1) {
throw new Error(`Missing required flag --${missingFlags[0]}`);
}

if (missingFlags.length > 1) {
const missingFlagsString = missingFlags.map((f) => `--${f}`).join(',');
const missingFlagsString = missingFlags.map(f => `--${f}`).join(',');
throw new Error('Missing required flags: ' + missingFlagsString);
}
}
Expand All @@ -39,8 +37,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
// define flags that can be inherited by any command that extends BaseCommand
static baseFlags = {
host: Flags.string({
description:
'CMS instance URL including scheme. For example: `https://my-instance.cms.optimizely.com`',
description: 'CMS instance URL including scheme. For example: `https://my-instance.cms.optimizely.com`',
}),
};

Expand Down
Loading
Loading