Skip to content

Commit f022aac

Browse files
authored
Merge pull request #6317 from Shopify/08-26-remove_spin_code
Remove spin code
2 parents 5aedb71 + 3abf276 commit f022aac

File tree

30 files changed

+22
-1005
lines changed

30 files changed

+22
-1005
lines changed

bin/docs/build-dev-docs.sh

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,3 @@ eval $COMPILE_DOCS
1515
eval $COMPILE_STATIC_PAGES
1616
eval $COMPILE_CATEGORY_PAGES
1717
echo "DONE"
18-
19-
if [ -n "$SPIN" ]; then
20-
if [ -n "$SPIN_SHOPIFY_DEV_SERVICE_FQDN" ]; then
21-
cp ./docs-shopify.dev/static/generated/* ~/src/github.com/Shopify/shopify-dev/db/data/docs/templated_apis/shopify-cli/v3/
22-
cp ./docs-shopify.dev/static/screenshots/* ~/src/github.com/Shopify/shopify-dev/app/assets/images/templated-apis-screenshots/shopify-cli/v3/
23-
else
24-
echo "If you include shopify-dev in your Spin constellation, this will automatically copy ./docs-shopify.dev/generated to shopify-dev"
25-
fi
26-
else
27-
echo "Not copying docs to shopify-dev because we're not in Spin"
28-
fi

bin/get-graphql-schemas.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -165,32 +165,6 @@ async function fetchFiles() {
165165
}
166166
}
167167

168-
/**
169-
* @returns {Promise<void>}
170-
*/
171-
async function fetchFilesFromSpin() {
172-
for (const schema of schemas) {
173-
const owner = schema.owner
174-
const repoName = schema.repo
175-
176-
const remotePath = `~/src/github.com/${owner}/${repoName}/${schema.pathToFile}`
177-
const localPath = schema.localPath
178-
try {
179-
await runCommand('spin', ['copy', `${process.env.SPIN_INSTANCE}:${remotePath}`, localPath])
180-
} catch(e) {
181-
if (e.message.match(/scp.*No such file or directory/)) {
182-
// Assume we need to just fetch the file from GitHub
183-
console.log(`Cannot find file for ${schema.repo} in Spin, fetching from GitHub instead...`)
184-
await withOctokit(schema.owner, async (octokit) => {
185-
await fetchFileForSchema(schema, octokit)
186-
})
187-
} else {
188-
throw e
189-
}
190-
}
191-
}
192-
}
193-
194168
/**
195169
* @returns {Promise<void>}
196170
*/
@@ -206,8 +180,6 @@ async function fetchFilesFromLocal() {
206180

207181
if (process.env.SHOPIFY_SERVICE_ENV === 'local') {
208182
fetchFilesFromLocal()
209-
} else if (process.env.SHOPIFY_SERVICE_ENV === 'spin') {
210-
fetchFilesFromSpin()
211183
} else {
212184
fetchFiles()
213185
}

bin/spin

Lines changed: 0 additions & 7 deletions
This file was deleted.

dev.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ commands:
5555
type-check:
5656
desc: 'Type-check the project'
5757
run: pnpm run type-check:affected
58-
spin:
59-
desc: 'Run commands in spin context'
60-
run: bin/spin
6158

6259
check:
6360
type-check: pnpm nx affected --target=type-check

packages/app/src/cli/services/dev/extension/server/utilities.test.ts

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import {testUIExtension} from '../../../../models/app/app.test-data.js'
33
import {ExtensionInstance} from '../../../../models/extensions/extension-instance.js'
44
import {ExtensionsPayloadStoreOptions} from '../payload/store.js'
55
import {describe, expect, test, vi} from 'vitest'
6-
import {isSpinEnvironment} from '@shopify/cli-kit/node/context/spin'
76

87
vi.mock('@shopify/cli-kit/node/context/local')
98
vi.mock('@shopify/cli-kit/node/system')
10-
vi.mock('@shopify/cli-kit/node/context/spin')
119

1210
describe('getRedirectURL()', () => {
1311
test('returns a URL with a URL param', async () => {
@@ -134,8 +132,7 @@ describe('getExtensionPointRedirectUrl()', () => {
134132
)
135133
})
136134

137-
test('returns customer account URL on shopify.com if the target is a customer account target and env is not spin', () => {
138-
vi.mocked(isSpinEnvironment).mockReturnValue(false)
135+
test('returns customer account URL on shopify.com if the target is a customer account target', () => {
139136
const extension = {
140137
devUUID: '123abc',
141138
} as ExtensionInstance
@@ -154,28 +151,7 @@ describe('getExtensionPointRedirectUrl()', () => {
154151
)
155152
})
156153

157-
test('returns customer account URL on a spin shopify domain if it is in a spin env', () => {
158-
vi.mocked(isSpinEnvironment).mockReturnValue(true)
159-
const extension = {
160-
devUUID: '123abc',
161-
} as ExtensionInstance
162-
163-
const options = {
164-
storeFqdn: 'shop1.shopify.spin-instance.us.spin.dev',
165-
storeId: '123456789',
166-
url: 'https://localhost:8081',
167-
id: 123,
168-
} as unknown as ExtensionsPayloadStoreOptions
169-
170-
const result = getExtensionPointRedirectUrl('customer-account.page.render', extension, options)
171-
172-
expect(result).toBe(
173-
'https://shopify.spin-instance.us.spin.dev/123456789/account/extensions-development?origin=https%3A%2F%2Flocalhost%3A8081%2Fextensions&extensionId=123abc&source=CUSTOMER_ACCOUNT_EXTENSION&appId=123&target=customer-account.page.render',
174-
)
175-
})
176-
177-
test('returns customer account URL on shopify.com if the extension point uses legacy customer account target and env is not spin', () => {
178-
vi.mocked(isSpinEnvironment).mockReturnValue(false)
154+
test('returns customer account URL on shopify.com if the extension point uses legacy customer account target', () => {
179155
const extension = {
180156
devUUID: '123abc',
181157
} as ExtensionInstance

packages/app/src/cli/services/dev/extension/server/utilities.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {getUIExtensionResourceURL} from '../../../../utilities/extensions/config
33
import {getExtensionPointTargetSurface} from '../utilities.js'
44
import {ExtensionsPayloadStoreOptions} from '../payload/store.js'
55
import {createError, H3Error, ServerResponse, sendError as h3SendError} from 'h3'
6-
import {isSpinEnvironment} from '@shopify/cli-kit/node/context/spin'
76

87
export function getRedirectUrl(extension: ExtensionInstance, options: ExtensionsPayloadStoreOptions): string {
98
const {url: resourceUrl} = getUIExtensionResourceURL(extension.type, options)
@@ -85,8 +84,7 @@ function getCustomerAccountsRedirectUrl(
8584
): URL {
8685
const origin = `${options.url}/extensions`
8786
const storeId = options.storeId
88-
const [_, ...storeDomainParts] = options.storeFqdn.split('.')
89-
const customerAccountHost = isSpinEnvironment() ? storeDomainParts.join('.') : 'shopify.com'
87+
const customerAccountHost = 'shopify.com'
9088
const rawUrl = new URL(`https://${customerAccountHost}/${storeId}/account/extensions-development`)
9189

9290
rawUrl.searchParams.append('origin', origin)

packages/app/src/cli/services/dev/processes/web.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {frontAndBackendConfig} from './utils.js'
33
import {Web, WebType} from '../../../models/app/app.js'
44
import {isWebType} from '../../../models/app/loader.js'
55
import {AbortSignal} from '@shopify/cli-kit/node/abort'
6-
import {isSpinEnvironment, spinFqdn} from '@shopify/cli-kit/node/context/spin'
76
import {getAvailableTCPPort} from '@shopify/cli-kit/node/tcp'
87
import {exec} from '@shopify/cli-kit/node/system'
98
import {isVerbose} from '@shopify/cli-kit/node/context/local'
@@ -50,7 +49,7 @@ export async function setupWebProcesses({
5049
const {frontendConfig} = frontAndBackendConfig(webs)
5150

5251
const hmrServerPort = frontendConfig?.configuration.hmr_server ? await getAvailableTCPPort() : undefined
53-
const shopCustomDomain = isSpinEnvironment() ? `shopify.${await spinFqdn()}` : undefined
52+
const shopCustomDomain = undefined
5453

5554
const webProcessSetups = webs.map(async (web) => {
5655
const port = await getWebProcessPort({web, frontendPort, backendPort})

packages/app/src/cli/services/dev/select-store.test.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ import {
77
} from '../../prompts/dev.js'
88
import {testDeveloperPlatformClient} from '../../models/app/app.test-data.js'
99
import {ClientName} from '../../utilities/developer-platform-client.js'
10-
import {beforeEach, describe, expect, vi, test} from 'vitest'
11-
import {isSpinEnvironment} from '@shopify/cli-kit/node/context/spin'
12-
import {firstPartyDev} from '@shopify/cli-kit/node/context/local'
10+
import {describe, expect, vi, test} from 'vitest'
1311

1412
vi.mock('../../prompts/dev')
1513
vi.mock('./fetch')
1614
vi.mock('@shopify/cli-kit/node/context/local')
1715
vi.mock('@shopify/cli-kit/node/system')
18-
vi.mock('@shopify/cli-kit/node/context/spin')
1916

2017
const ORG1: Organization = {
2118
id: '1',
@@ -54,10 +51,6 @@ const STORE3: OrganizationStore = {
5451

5552
const defaultShowDomainOnPrompt = false
5653

57-
beforeEach(() => {
58-
vi.mocked(isSpinEnvironment).mockReturnValue(false)
59-
})
60-
6154
describe('selectStore', async () => {
6255
test('prompts user to select', async () => {
6356
// Given
@@ -145,27 +138,6 @@ describe('selectStore', async () => {
145138
expect(confirmConversionToTransferDisabledStorePrompt).toHaveBeenCalled()
146139
})
147140

148-
test('not prompts user to convert store to non-transferable if selection is invalid inside spin instance and first party', async () => {
149-
// Given
150-
vi.mocked(selectStorePrompt).mockResolvedValueOnce(STORE2)
151-
vi.mocked(isSpinEnvironment).mockReturnValue(true)
152-
vi.mocked(firstPartyDev).mockReturnValue(true)
153-
const developerPlatformClient = testDeveloperPlatformClient({clientName: ClientName.Partners})
154-
155-
// When
156-
const got = await selectStore({stores: [STORE1, STORE2], hasMorePages: false}, ORG1, developerPlatformClient)
157-
158-
// Then
159-
expect(got).toEqual(STORE2)
160-
expect(developerPlatformClient.convertToTransferDisabledStore).not.toHaveBeenCalled()
161-
expect(selectStorePrompt).toHaveBeenCalledWith(
162-
expect.objectContaining({
163-
stores: [STORE1, STORE2],
164-
showDomainOnPrompt: defaultShowDomainOnPrompt,
165-
}),
166-
)
167-
})
168-
169141
test('throws if store is non convertible', async () => {
170142
// Given
171143
vi.mocked(selectStorePrompt).mockResolvedValueOnce(STORE3)

packages/app/src/cli/services/dev/select-store.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ export async function convertToTransferDisabledStoreIfNeeded(
130130
developerPlatformClient: DeveloperPlatformClient,
131131
conversionMode: 'prompt-first' | 'never',
132132
): Promise<boolean> {
133-
/**
134-
* It's not possible to convert stores to dev ones in spin environments. Should be created directly as development.
135-
* Against production (!isSpinEnvironment()), this allows you to reference other shops in a TOML file even if some of
136-
* the dev experience isn't completely supported.
137-
*/
138133
if (store.transferDisabled || firstPartyDev()) return true
139134

140135
if (!store.transferDisabled && !store.convertableToPartnerTest) {

packages/app/src/cli/services/dev/urls.test.ts

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import {setManyAppConfigValues} from '../app/patch-app-configuration-file.js'
1919
import {AppLinkedInterface} from '../../models/app/app.js'
2020
import {beforeEach, describe, expect, vi, test} from 'vitest'
2121
import {AbortError} from '@shopify/cli-kit/node/error'
22-
import {checkPortAvailability, getAvailableTCPPort} from '@shopify/cli-kit/node/tcp'
23-
import {isSpin, spinFqdn, appPort, appHost, fetchSpinPort} from '@shopify/cli-kit/node/context/spin'
22+
import {getAvailableTCPPort} from '@shopify/cli-kit/node/tcp'
2423
import {codespacePortForwardingDomain, codespaceURL, gitpodURL, isUnitTest} from '@shopify/cli-kit/node/context/local'
2524
import {renderConfirmationPrompt, renderSelectPrompt} from '@shopify/cli-kit/node/ui'
2625
import {terminalSupportsPrompting} from '@shopify/cli-kit/node/system'
@@ -32,7 +31,6 @@ vi.mock('../app/patch-app-configuration-file.js', () => {
3231
}
3332
})
3433
vi.mock('@shopify/cli-kit/node/tcp')
35-
vi.mock('@shopify/cli-kit/node/context/spin')
3634
vi.mock('@shopify/cli-kit/node/context/local')
3735
vi.mock('@shopify/cli-kit/node/plugins')
3836
vi.mock('@shopify/cli-kit/node/ui')
@@ -487,96 +485,6 @@ describe('generateFrontendURL', () => {
487485
expect(setCachedAppInfo).not.toBeCalled()
488486
expect(renderSelectPrompt).not.toBeCalled()
489487
})
490-
491-
test('Returns a cli spin url if we are in a spin environment running the cli manually', async () => {
492-
// Given
493-
vi.mocked(isSpin).mockReturnValue(true)
494-
vi.mocked(spinFqdn).mockResolvedValue('spin.domain.dev')
495-
vi.mocked(appPort).mockReturnValue(undefined)
496-
vi.mocked(fetchSpinPort).mockResolvedValue(4040)
497-
498-
// When
499-
const got = await generateFrontendURL(defaultOptions)
500-
501-
// Then
502-
expect(got).toEqual({
503-
frontendUrl: 'https://cli.spin.domain.dev',
504-
frontendPort: 4040,
505-
usingLocalhost: false,
506-
})
507-
expect(setCachedAppInfo).not.toBeCalled()
508-
expect(renderSelectPrompt).not.toBeCalled()
509-
})
510-
511-
test('Returns a 1p app spin url if we are in a spin environment running the cli as service', async () => {
512-
// Given
513-
vi.mocked(isSpin).mockReturnValue(true)
514-
vi.mocked(appPort).mockReturnValue(1234)
515-
vi.mocked(appHost).mockReturnValue('1p-app-host.spin.domain.dev')
516-
vi.mocked(checkPortAvailability).mockResolvedValue(true)
517-
518-
// When
519-
const got = await generateFrontendURL(defaultOptions)
520-
521-
// Then
522-
expect(got).toEqual({
523-
frontendUrl: 'https://1p-app-host.spin.domain.dev',
524-
frontendPort: 1234,
525-
usingLocalhost: false,
526-
})
527-
expect(setCachedAppInfo).not.toBeCalled()
528-
expect(renderSelectPrompt).not.toBeCalled()
529-
})
530-
531-
test('Returns a cli spin url if we are in a spin environment running the cli manually with a 1p app backend running as service', async () => {
532-
// Given
533-
vi.mocked(isSpin).mockReturnValue(true)
534-
vi.mocked(appPort).mockReturnValue(1234)
535-
vi.mocked(spinFqdn).mockResolvedValue('spin.domain.dev')
536-
vi.mocked(checkPortAvailability).mockResolvedValue(false)
537-
vi.mocked(fetchSpinPort).mockResolvedValue(4040)
538-
539-
// When
540-
const got = await generateFrontendURL(defaultOptions)
541-
542-
// Then
543-
expect(got).toEqual({
544-
frontendUrl: 'https://cli.spin.domain.dev',
545-
frontendPort: 4040,
546-
usingLocalhost: false,
547-
})
548-
expect(setCachedAppInfo).not.toBeCalled()
549-
expect(renderSelectPrompt).not.toBeCalled()
550-
})
551-
552-
test('Returns an error if we are in a spin environment with a 1p app backend is running as service and the partners port is not configured', async () => {
553-
// Given
554-
vi.mocked(isSpin).mockReturnValue(true)
555-
vi.mocked(appPort).mockReturnValue(1234)
556-
vi.mocked(spinFqdn).mockResolvedValue('spin.domain.dev')
557-
vi.mocked(checkPortAvailability).mockResolvedValue(false)
558-
vi.mocked(fetchSpinPort).mockResolvedValue(undefined)
559-
560-
// When
561-
const got = generateFrontendURL(defaultOptions)
562-
563-
// Then
564-
await expect(got).rejects.toThrow(
565-
'Error building cli url in spin, cli as service port: 1234, manual cli port: undefined',
566-
)
567-
})
568-
569-
test('Returns a custom tunnel url if we are in a spin environment but a custom tunnel option is active', async () => {
570-
// Given
571-
vi.mocked(isSpin).mockReturnValue(true)
572-
const options = {...defaultOptions, tunnelUrl: 'https://my-tunnel-provider.io:4242'}
573-
574-
// When
575-
const got = await generateFrontendURL(options)
576-
577-
// Then
578-
expect(got).toEqual({frontendUrl: 'https://my-tunnel-provider.io', frontendPort: 4242, usingLocalhost: false})
579-
})
580488
})
581489

582490
describe('generatePartnersURLs', () => {

0 commit comments

Comments
 (0)