Skip to content

Commit

Permalink
Merge branch 'develop' into fix/invites-in-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed May 22, 2024
2 parents 9fc5e51 + bb5872d commit 2761dfa
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 58 deletions.
2 changes: 1 addition & 1 deletion packages/admin-next/admin-sdk/src/lib/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function serve(options: ServeOptions) {

if (!indexExists) {
throw new Error(
`Could not find the admin UI build files. Please run "medusa-admin build" or enable "autoRebuild" in the plugin options to build the admin UI.`
`Could not find the admin UI build files. Please run \`npm run build\` or \`yarn build\` command and try again.`
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ const LoggedInUser = () => {
<DropdownMenu.Content align="center">
<Profile />
<DropdownMenu.Separator />
<Link to="https://docs.medusajs.com/user-guide" target="_blank">
<Link
// TODO change link once docs are public
to="https://medusa-docs-v2-git-docs-v2-medusajs.vercel.app/"
target="_blank"
>
<DropdownMenu.Item>
<BookOpen className="text-ui-fg-subtle mr-2" />
Documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export const EditProfileForm = ({ user, usageInsights }: EditProfileProps) => {
<a
key="hint-link"
className="text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg underline"
href="https://docs.medusajs.com/usage#admin-analytics"
// TODO change link once docs are public
href="https://medusa-resources-git-docs-v2-medusajs.vercel.app/resources/usage#admin-analytics"
target="_blank"
rel="noopener noreferrer"
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const CreateReservationForm = () => {
size="small"
isLoading={isPending}
>
{t("actions.reservation")}
{t("actions.create")}
</Button>
</div>
</RouteFocusModal.Header>
Expand Down
29 changes: 8 additions & 21 deletions packages/cli/create-medusa-app/src/utils/prepare-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,30 +226,17 @@ export default async ({
title: "Seeding database...",
})

const seedScriptPath = path.join("dist", "helpers", "seed.js")

// check if a seed file exists in the project
if (!fs.existsSync(path.join(directory, seedScriptPath))) {
spinner
?.warn(
chalk.yellow(
"Seed file was not found in the project. Skipping seeding..."
)
)
.start()
return inviteToken
}

await processManager.runProcess({
process: async () => {
await execute(
[
`npx medusa exec ${seedScriptPath}`,
npxOptions,
],
{ verbose }
)
try {
await execute([`yarn seed`, execOptions], { verbose })
} catch (e) {
// yarn isn't available
// use npm
await execute([`npm run seed`, execOptions], { verbose })
}
},
ignoreERESOLVE: true,
})

displayFactBox({
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/medusa-cli/src/reporter/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { track } from "medusa-telemetry"
import ora from "ora"
import stackTrace from "stack-trace"
import { ulid } from "ulid"
import winston from "winston"
import ora from "ora"
import { track } from "medusa-telemetry"

import { panicHandler } from "./panic-handler"
import * as Transport from "winston-transport"
import { panicHandler } from "./panic-handler"

const LOG_LEVEL = process.env.LOG_LEVEL || "silly"
const LOG_LEVEL = process.env.LOG_LEVEL || "info"
const LOG_FILE = process.env.LOG_FILE || ""
const NODE_ENV = process.env.NODE_ENV || "development"
const IS_DEV = NODE_ENV.startsWith("dev")
Expand Down
18 changes: 4 additions & 14 deletions packages/core/types/src/common/config-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type AdminOptions = {
/**
* Configure the Vite configuration for the admin dashboard. This function receives the default Vite configuration
* and returns the modified configuration. The default value is `undefined`.
*
*
* @privateRemarks TODO Add example
*/
vite?: (config: InlineConfig) => InlineConfig
Expand Down Expand Up @@ -401,9 +401,9 @@ export type ProjectConfigOptions = {
* // ...
* }
* ```
*
*
* @deprecated use {@link http }'s `compression` property instead.
*
*
*/
http_compression?: HttpCompressionOptions

Expand Down Expand Up @@ -751,7 +751,7 @@ export type ConfigModule = {

/**
* Admin dashboard configurations.
*
*
* @example
* ```js title="medusa-config.js"
* module.exports = {
Expand Down Expand Up @@ -875,16 +875,6 @@ export type ConfigModule = {
* :::
*/
featureFlags: Record<string, boolean | string>

/**
* @ignore
*
* @privateRemarks
* Since this is a temporary config, maybe let's not include it in the generated reference for now.
*/
directories?: {
srcDir?: string
}
}

export type PluginDetails = {
Expand Down
1 change: 0 additions & 1 deletion packages/medusa/src/commands/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const runLinkMigrations = async (directory) => {

const main = async function ({ directory }) {
const args = process.argv

args.shift()
args.shift()
args.shift()
Expand Down
6 changes: 6 additions & 0 deletions packages/medusa/src/commands/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export default async function ({
track("CLI_USER", { with_id: !!id })
const app = express()
try {
/**
* Enabling worker mode to prevent discovering/loading
* of API routes from the starter kit
*/
process.env.MEDUSA_WORKER_MODE = "worker"

const { container } = await loaders({
directory,
expressApp: app,
Expand Down
3 changes: 0 additions & 3 deletions packages/medusa/src/loaders/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,5 @@ export default (rootDirectory: string): ConfigModule => {
modules: configModule.modules ?? {},
featureFlags: configModule?.featureFlags ?? {},
plugins: configModule?.plugins ?? [],
directories: configModule?.directories ?? {
srcDir: "dist",
},
}
}
15 changes: 8 additions & 7 deletions packages/medusa/src/loaders/helpers/resolve-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,22 @@ function resolvePlugin(pluginName: string): {

export function getResolvedPlugins(
rootDirectory: string,
configModule: {
plugins: ConfigModule["plugins"]
directories?: ConfigModule["directories"]
},
configModule: ConfigModule,
isMedusaProject = false
): undefined | PluginDetails[] {
if (isMedusaProject) {
/**
* Grab directory for loading resources inside a starter kit from
* the medusa-config file.
*
* This is because, we do not have a "dist" directory inside a starter
* kit. Instead we discover resources from the "src" directory.
* When using ts-node we will read resources from "src" directory
* otherwise from "dist" directory.
*/
const extensionDirectoryPath = configModule.directories?.srcDir ?? "dist"
const extensionDirectoryPath = process[
Symbol.for("ts-node.register.instance")
]
? "src"
: "dist"
const extensionDirectory = path.join(rootDirectory, extensionDirectoryPath)
return [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/medusa/src/loaders/helpers/routing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const log = ({
return
}

logger.info(message)
logger.debug(message)
}

/**
Expand Down
11 changes: 8 additions & 3 deletions packages/modules/link-modules/src/utils/generate-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export function generateGraphQLSchema(
let fieldNames!: string[]
let entityName!: string

if (!joinerConfig.isReadOnlyLink) {
const isReadOnlyLink = joinerConfig.isReadOnlyLink
if (!isReadOnlyLink) {
fieldNames = primary.foreignKey.split(",").concat(foreign.foreignKey)

entityName = toPascalCase(
Expand All @@ -31,7 +32,11 @@ export function generateGraphQLSchema(

for (const extend of joinerConfig.extends ?? []) {
const extendedModule = MedusaModule.getModuleInstance(extend.serviceName)
if (!extendedModule && !extend.relationship.isInternalService) {
if (
!isReadOnlyLink &&
!extendedModule &&
!extend.relationship.isInternalService
) {
throw new Error(
`Module ${extend.serviceName} not found. Please verify that the module is configured and installed, also the module must be loaded before the link modules.`
)
Expand Down Expand Up @@ -69,7 +74,7 @@ export function generateGraphQLSchema(
`
}

if (joinerConfig.isReadOnlyLink) {
if (isReadOnlyLink) {
return typeDef
}

Expand Down

0 comments on commit 2761dfa

Please sign in to comment.