-
Notifications
You must be signed in to change notification settings - Fork 233
Integrate Project model into loader and decompose into composable stages #7023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ryancbahan
wants to merge
21
commits into
main
Choose a base branch
from
rcb/project-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
1e81644
Integrate Project model into loader and app-context
ryancbahan e775694
Decompose loader into composable stages with narrow interfaces
ryancbahan e4487d9
fix rebase artifacts: conflict marker, missing import, missing config…
ryancbahan c2ace14
fix activeConfigFile getter: use configPath instead of configuration.…
ryancbahan 5f12f8e
fix lint: unused import, unnecessary type assertion, extra blank line
ryancbahan 7e87e29
address review: remove dead fallback, extract config-file-naming utility
ryancbahan 9d589df
add integration tests for reload with new extensions mid-dev
ryancbahan cd3647e
fix dev reload: ensure extension dirs exist + always write manifest
ryancbahan 2c3b45a
fix lint and type errors in project-integration tests
ryancbahan 193d440
add unit tests for config-file-naming utility
ryancbahan ffeb48f
fix mkdir with glob suffixes, drop .gitkeep, add comment on client_id…
ryancbahan 87cf67c
clean up loader: remove vestigial delete rawConfig.path, single metad…
ryancbahan be1b734
reduce CI memory pressure: hoist loadLocalExtensionsSpecifications
ryancbahan 852487b
fix CI crash: catch mkdir errors in file watcher, reduce test memory
ryancbahan b8a27ef
fix CI: mock AppEventWatcher.start in useFunctionWatcher tests
ryancbahan 378611c
fix lint: remove manual vi.restoreAllMocks (vitest does it automatica…
ryancbahan c6ef6fd
Add e2e tests for multi-config dev and hot reload
ryancbahan 5418467
address review: remove dead _extensionDirectories param, narrow setCu…
ryancbahan c5eef3c
fix e2e: use undefined (not empty string) to remove SHOPIFY_FLAG_CLIE…
ryancbahan c5331be
address review: preserve glob semantics in config filtering, make use…
ryancbahan 1e6e6de
add dev session test for extension created mid-dev
ryancbahan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/app/src/cli/models/app/config-file-naming.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { | ||
| getAppConfigurationFileName, | ||
| getAppConfigurationShorthand, | ||
| isValidFormatAppConfigurationFileName, | ||
| } from './config-file-naming.js' | ||
| import {describe, expect, test} from 'vitest' | ||
|
|
||
| describe('getAppConfigurationFileName', () => { | ||
| test('returns default filename when no config name is provided', () => { | ||
| expect(getAppConfigurationFileName()).toBe('shopify.app.toml') | ||
| expect(getAppConfigurationFileName(undefined)).toBe('shopify.app.toml') | ||
| }) | ||
|
|
||
| test('returns the config name as-is when it matches the valid format', () => { | ||
| expect(getAppConfigurationFileName('shopify.app.production.toml')).toBe('shopify.app.production.toml') | ||
| expect(getAppConfigurationFileName('shopify.app.staging.toml')).toBe('shopify.app.staging.toml') | ||
| expect(getAppConfigurationFileName('shopify.app.toml')).toBe('shopify.app.toml') | ||
| }) | ||
|
|
||
| test('slugifies arbitrary strings into the filename pattern', () => { | ||
| expect(getAppConfigurationFileName('production')).toBe('shopify.app.production.toml') | ||
| expect(getAppConfigurationFileName('My Store')).toBe('shopify.app.my-store.toml') | ||
| }) | ||
| }) | ||
|
|
||
| describe('getAppConfigurationShorthand', () => { | ||
| test('returns undefined for the default config filename', () => { | ||
| expect(getAppConfigurationShorthand('shopify.app.toml')).toBeUndefined() | ||
| expect(getAppConfigurationShorthand('/some/path/shopify.app.toml')).toBeUndefined() | ||
| }) | ||
|
|
||
| test('extracts the shorthand from a named config', () => { | ||
| expect(getAppConfigurationShorthand('shopify.app.production.toml')).toBe('production') | ||
| expect(getAppConfigurationShorthand('/path/to/shopify.app.staging.toml')).toBe('staging') | ||
| expect(getAppConfigurationShorthand('shopify.app.my-store.toml')).toBe('my-store') | ||
| }) | ||
|
|
||
| test('returns undefined for non-matching filenames', () => { | ||
| expect(getAppConfigurationShorthand('random.toml')).toBeUndefined() | ||
| expect(getAppConfigurationShorthand('shopify.web.toml')).toBeUndefined() | ||
| }) | ||
| }) | ||
|
|
||
| describe('isValidFormatAppConfigurationFileName', () => { | ||
| test('returns true for valid app configuration filenames', () => { | ||
| expect(isValidFormatAppConfigurationFileName('shopify.app.toml')).toBe(true) | ||
| expect(isValidFormatAppConfigurationFileName('shopify.app.production.toml')).toBe(true) | ||
| expect(isValidFormatAppConfigurationFileName('shopify.app.my-store.toml')).toBe(true) | ||
| expect(isValidFormatAppConfigurationFileName('shopify.app.test_env.toml')).toBe(true) | ||
| }) | ||
|
|
||
| test('returns false for invalid filenames', () => { | ||
| expect(isValidFormatAppConfigurationFileName('production')).toBe(false) | ||
| expect(isValidFormatAppConfigurationFileName('shopify.web.toml')).toBe(false) | ||
| expect(isValidFormatAppConfigurationFileName('shopify.app..toml')).toBe(false) | ||
| expect(isValidFormatAppConfigurationFileName('')).toBe(false) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import {configurationFileNames} from '../../constants.js' | ||
| import {slugify} from '@shopify/cli-kit/common/string' | ||
| import {basename} from '@shopify/cli-kit/node/path' | ||
|
|
||
| const appConfigurationFileNameRegex = /^shopify\.app(\.[-\w]+)?\.toml$/ | ||
| export type AppConfigurationFileName = 'shopify.app.toml' | `shopify.app.${string}.toml` | ||
|
|
||
| /** | ||
| * Gets the name of the app configuration file (e.g. `shopify.app.production.toml`) based on a provided config name. | ||
| * | ||
| * @param configName - Optional config name to base the file name upon | ||
| * @returns Either the default app configuration file name (`shopify.app.toml`), the given config name (if it matched the valid format), or `shopify.app.<config name>.toml` if it was an arbitrary string | ||
| */ | ||
| export function getAppConfigurationFileName(configName?: string): AppConfigurationFileName { | ||
| if (!configName) { | ||
| return configurationFileNames.app | ||
| } | ||
|
|
||
| if (isValidFormatAppConfigurationFileName(configName)) { | ||
| return configName | ||
| } else { | ||
| return `shopify.app.${slugify(configName)}.toml` | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Given a path to an app configuration file, extract the shorthand section from the file name. | ||
| * | ||
| * This is undefined for `shopify.app.toml` files, or returns e.g. `production` for `shopify.app.production.toml`. | ||
| */ | ||
| export function getAppConfigurationShorthand(path: string) { | ||
| const match = basename(path).match(appConfigurationFileNameRegex) | ||
| return match?.[1]?.slice(1) | ||
| } | ||
|
|
||
| /** Checks if configName is a valid one (`shopify.app.toml`, or `shopify.app.<something>.toml`) */ | ||
| export function isValidFormatAppConfigurationFileName(configName: string): configName is AppConfigurationFileName { | ||
| if (appConfigurationFileNameRegex.test(configName)) { | ||
| return true | ||
| } | ||
| return false | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.