Skip to content

Commit

Permalink
Attempt to fix build config
Browse files Browse the repository at this point in the history
  • Loading branch information
patdx committed Jul 9, 2024
1 parent 7d888b4 commit e5e6433
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- uses: pnpm/action-setup@v2
name: Install pnpm
Expand Down
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
"cSpell.words": ["rjsf"],
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
}
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
9 changes: 8 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
"linter": {
"enabled": true,
"rules": {
"recommended": true
"recommended": true,
"style": {
"noUselessElse": "off"
},
"suspicious": {
"noExplicitAny": "off",
"noImplicitAnyLet": "off"
}
}
}
}
4 changes: 2 additions & 2 deletions scripts/generate-wrangler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import TOML from '@ltd/j-toml';
import fs from 'fs';
import child_process from 'child_process';
import fs from 'node:fs';
import child_process from 'node:child_process';

/** @type {import('../secrets.json') | undefined} */
let secrets = undefined;
Expand Down
8 changes: 7 additions & 1 deletion src/adapter-cloudflare-pages/adapter-cloudflare-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const adapterCloudflarePages: RakkasAdapter = {
// await fs.promises.writeFile(entry, CLOUDFLARE_WORKERS_ENTRY);
// }

console.log('Start bundling cloudflare pages');

await cloudflareWorkers(
{
output: path.resolve(root, 'dist/client/_worker.js'),
Expand All @@ -32,8 +34,12 @@ export const adapterCloudflarePages: RakkasAdapter = {
// options.minify = false;
options.define = options.define || {};
options.define['process.env.RAKKAS_PRERENDER'] = 'undefined';
options.define['global'] = 'globalThis';
options.define.global = 'globalThis';
options.external = options.external || [];
options.external.push('node:async_hooks');
},
);

console.log('Done bundling cloudflare pages');
},
};
2 changes: 1 addition & 1 deletion src/db/migrator/system-tables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Static, Type } from '@sinclair/typebox';
import { type Static, Type } from '@sinclair/typebox';
import type { JSONSchema6 } from 'json-schema';

export const systemTables = {
Expand Down
30 changes: 8 additions & 22 deletions src/db/sql-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const format = function format(sql, values, stringifyObjects, timeZone) {
return sql;
}

if (!(values instanceof Array || Array.isArray(values))) {
if (!Array.isArray(values)) {
values = [values];
}

Expand Down Expand Up @@ -158,26 +158,13 @@ export const dateToString = function dateToString(date, timeZone) {
}

// YYYY-MM-DD HH:mm:ss.mmm
const str =
zeroPad(year, 4) +
'-' +
zeroPad(month, 2) +
'-' +
zeroPad(day, 2) +
' ' +
zeroPad(hour, 2) +
':' +
zeroPad(minute, 2) +
':' +
zeroPad(second, 2) +
'.' +
zeroPad(millisecond, 3);
const str = `${zeroPad(year, 4)}-${zeroPad(month, 2)}-${zeroPad(day, 2)} ${zeroPad(hour, 2)}:${zeroPad(minute, 2)}:${zeroPad(second, 2)}.${zeroPad(millisecond, 3)}`;

return escapeString(str);
};

export const bufferToString = function bufferToString(buffer) {
return 'X' + escapeString(buffer.toString('hex'));
return `X${escapeString(buffer.toString('hex'))}`;
};

export const objectToValues = function objectToValues(object, timeZone) {
Expand All @@ -190,11 +177,9 @@ export const objectToValues = function objectToValues(object, timeZone) {
continue;
}

sql +=
(sql.length === 0 ? '' : ', ') +
escapeId(key) +
' = ' +
escape(val, true, timeZone);
sql += `${
(sql.length === 0 ? '' : ', ') + escapeId(key)
} = ${escape(val, true, timeZone)}`;
}

return sql;
Expand Down Expand Up @@ -253,7 +238,8 @@ function convertTimezone(tz) {
if (m) {
return (
(m[1] === '-' ? -1 : 1) *
(parseInt(m[2], 10) + (m[3] ? parseInt(m[3], 10) : 0) / 60) *
(Number.parseInt(m[2], 10) +
(m[3] ? Number.parseInt(m[3], 10) : 0) / 60) *
60
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/entry-hattip.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createRequestHandler } from 'rakkasjs';
import { createRequestHandler } from 'rakkasjs/server';

export default createRequestHandler();
4 changes: 2 additions & 2 deletions src/entry-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createMiddleware } from 'rakkasjs/node-adapter';
import hattipHandler from './entry-hattip';
import { D1Database, D1DatabaseAPI } from '@miniflare/d1';
import { createSQLiteDB } from '@miniflare/shared';
import fs from 'fs';
import fs from 'node:fs';

fs.mkdirSync('./data', { recursive: true });

Expand All @@ -13,7 +13,7 @@ const dbPromise = Promise.resolve()
.then(async (db) => {
// simulate the extra system tables of the real cloudflare d1 database
await db.exec(
`CREATE TABLE IF NOT EXISTS d1_kv (key TEXT PRIMARY KEY, value TEXT)`,
'CREATE TABLE IF NOT EXISTS d1_kv (key TEXT PRIMARY KEY, value TEXT)',
);

return db;
Expand Down
22 changes: 11 additions & 11 deletions src/json-schema-form.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import type { FormProps } from '@rjsf/core';
import {
FieldTemplateProps,
FormContextType,
type FieldTemplateProps,
type FormContextType,
getInputProps,
getSubmitButtonOptions,
getTemplate,
getUiOptions,
RegistryWidgetsType,
RJSFSchema,
StrictRJSFSchema,
SubmitButtonProps,
WidgetProps,
type RegistryWidgetsType,
type RJSFSchema,
type StrictRJSFSchema,
type SubmitButtonProps,
type WidgetProps,
} from '@rjsf/utils';
import validator from '@rjsf/validator-ajv8';
import dirtyJSON from 'dirty-json';
import type { JSONSchema6 } from 'json-schema';
import { useRef, useCallback, forwardRef, useState, FocusEvent } from 'react';
import { useRef, useCallback, forwardRef, useState, type FocusEvent } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { Details } from './components/details';
import { ThemeProps, withTheme } from '@rjsf/core';
import { type ThemeProps, withTheme } from '@rjsf/core';
import clsx from 'clsx';
import MonacoEditor from '@monaco-editor/react';
import jsonSchemaDraft7 from './json-schema-draft-7.json'; // https://github.com/json-schema-org/json-schema-spec/issues/1007
Expand Down Expand Up @@ -53,8 +53,8 @@ const tryCompactJson = (maybeJson?: string): string => {
}
};

const JsonTextEdit = function (props: WidgetProps) {
let defaultValue = tryFormatJson(props.value);
const JsonTextEdit = (props: WidgetProps) => {
const defaultValue = tryFormatJson(props.value);

// const lines = Math.max(value.split("\n").length, 5);

Expand Down
2 changes: 1 addition & 1 deletion src/routes/[entity]/[id].page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx';
import { Link, Page, PageProps, useServerSideQuery } from 'rakkasjs';
import { Link, type Page, type PageProps, useServerSideQuery } from 'rakkasjs';
import { ViewEntity } from 'src/components/view-entity';
import { loadEntityData } from 'src/db/load-entity-data';
import { useDeleteMutation } from 'src/db/use-delete-mutation';
Expand Down
7 changes: 3 additions & 4 deletions src/utils/format-sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ export const formatSql = (
} catch (err) {
if (options?.throwOnError) {
throw err;
} else {
console.log('Error while formatting:');
console.warn(err);
return query;
}
console.log('Error while formatting:');
console.warn(err);
return query;
}
};

0 comments on commit e5e6433

Please sign in to comment.