Skip to content

Commit

Permalink
refactor: revert appVersion changes to rely on sdkVersion for now
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Apr 26, 2024
1 parent 7441461 commit 85abf50
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 127 deletions.
2 changes: 1 addition & 1 deletion packages/snack-content/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snack-content",
"version": "2.1.0",
"version": "2.0.0",
"description": "Functions and types that describe the contents of Snack projects",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
114 changes: 14 additions & 100 deletions packages/snack-content/src/__tests__/urls-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,41 @@ const channel = 'AsZ12sasd11G';

describe(createRuntimeUrl, () => {
it('returns url with only "sdkVersion"', () => {
expect(createRuntimeUrl({ sdkVersion: '51.0.0' })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=51.0.0&channel-name=production"`,
expect(createRuntimeUrl({ sdkVersion: '50.0.0' })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A50.0.0&channel-name=production"`,
);
});

it(`returns url with "sdkVersion" and "snack"`, () => {
expect(createRuntimeUrl({ sdkVersion: '52.0.0', snack })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=52.0.0&channel-name=production&snack=xxxxxx"`,
expect(createRuntimeUrl({ sdkVersion: '49.0.0', snack })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A49.0.0&channel-name=production&snack=xxxxxx"`,
);
});

it(`returns url with "sdkVersion" and "channel"`, () => {
expect(createRuntimeUrl({ sdkVersion: '53.0.0', channel })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=53.0.0&channel-name=production&snack-channel=AsZ12sasd11G"`,
expect(createRuntimeUrl({ sdkVersion: '48.0.0', channel })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A48.0.0&channel-name=production&snack-channel=AsZ12sasd11G"`,
);
});

it(`returns url with "sdkVersion", "snack", and "channel"`, () => {
expect(createRuntimeUrl({ sdkVersion: '54.0.0', snack, channel })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=54.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`,
expect(createRuntimeUrl({ sdkVersion: '50.0.0', snack, channel })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A50.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`,
);
});

it(`returns url with "sdkVersion", "snack", and "channel" using custom "endpoint"`, () => {
expect(
createRuntimeUrl({ sdkVersion: '55.0.0', snack, channel, endpoint: 'u-dev.expo.test/xxx' }),
createRuntimeUrl({ sdkVersion: '49.0.0', snack, channel, endpoint: 'u-dev.expo.test/xxx' }),
).toMatchInlineSnapshot(
`"exp://u-dev.expo.test/xxx?runtime-version=55.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`,
`"exp://u-dev.expo.test/xxx?runtime-version=exposdk%3A49.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`,
);
});

describe('SDK <=50 legacy runtime sdkVersion (exposdk:*)', () => {
it('returns url with only "sdkVersion"', () => {
expect(createRuntimeUrl({ sdkVersion: '50.0.0' })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A50.0.0&channel-name=production"`,
);
});

it(`returns url with "sdkVersion" and "snack"`, () => {
expect(createRuntimeUrl({ sdkVersion: '49.0.0', snack })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A49.0.0&channel-name=production&snack=xxxxxx"`,
);
});

it(`returns url with "sdkVersion" and "channel"`, () => {
expect(createRuntimeUrl({ sdkVersion: '48.0.0', channel })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A48.0.0&channel-name=production&snack-channel=AsZ12sasd11G"`,
);
});

it(`returns url with "sdkVersion", "snack", and "channel"`, () => {
expect(createRuntimeUrl({ sdkVersion: '50.0.0', snack, channel })).toMatchInlineSnapshot(
`"exp://u.expo.dev/933fd9c0-1666-11e7-afca-d980795c5824?runtime-version=exposdk%3A50.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`,
);
});

it(`returns url with "sdkVersion", "snack", and "channel" using custom "endpoint"`, () => {
expect(
createRuntimeUrl({ sdkVersion: '49.0.0', snack, channel, endpoint: 'u-dev.expo.test/xxx' }),
).toMatchInlineSnapshot(
`"exp://u-dev.expo.test/xxx?runtime-version=exposdk%3A49.0.0&channel-name=production&snack=xxxxxx&snack-channel=AsZ12sasd11G"`,
);
});
});
});

describe(parseRuntimeUrl, () => {
it('returns info with only "sdkVersion"', () => {
expect(parseRuntimeUrl('exp://u.expo.dev/xxx?runtime-version=69.0.0'))
expect(parseRuntimeUrl('exp://u.expo.dev/xxx?runtime-version=exposdk:69.0.0'))
.toMatchInlineSnapshot(`
Object {
"channel": undefined,
Expand All @@ -84,7 +50,7 @@ describe(parseRuntimeUrl, () => {
});

it('returns info with "sdkVersion" and "snack"', () => {
expect(parseRuntimeUrl('exp://u.expo.dev/xxx?runtime-version=69.0.0&snack=snackid'))
expect(parseRuntimeUrl('exp://u.expo.dev/xxx?runtime-version=exposdk:69.0.0&snack=snackid'))
.toMatchInlineSnapshot(`
Object {
"channel": undefined,
Expand All @@ -97,7 +63,7 @@ describe(parseRuntimeUrl, () => {
it('returns info with "sdkVersion" and "channel"', () => {
expect(
parseRuntimeUrl(
'exp://u.expo.dev/xxx?runtime-version=69.0.0&snack-channel=channelid',
'exp://u.expo.dev/xxx?runtime-version=exposdk:69.0.0&snack-channel=channelid',
),
).toMatchInlineSnapshot(`
Object {
Expand All @@ -111,7 +77,7 @@ describe(parseRuntimeUrl, () => {
it('returns info with "sdkVersion", "snack", and "channel"', () => {
expect(
parseRuntimeUrl(
'exp://u.expo.dev/xxx?runtime-version=69.0.0&snack=snackid&snack-channel=channelid',
'exp://u.expo.dev/xxx?runtime-version=exposdk:69.0.0&snack=snackid&snack-channel=channelid',
),
).toMatchInlineSnapshot(`
Object {
Expand All @@ -121,56 +87,4 @@ describe(parseRuntimeUrl, () => {
}
`);
});

describe('SDK <=50 legacy runtime sdkVersion (exposdk:*)', () => {
it('returns info with only "sdkVersion"', () => {
expect(parseRuntimeUrl('exp://u.expo.dev/xxx?runtime-version=exposdk:69.0.0'))
.toMatchInlineSnapshot(`
Object {
"channel": undefined,
"sdkVersion": "69.0.0",
"snack": undefined,
}
`);
});

it('returns info with "sdkVersion" and "snack"', () => {
expect(parseRuntimeUrl('exp://u.expo.dev/xxx?runtime-version=exposdk:69.0.0&snack=snackid'))
.toMatchInlineSnapshot(`
Object {
"channel": undefined,
"sdkVersion": "69.0.0",
"snack": "snackid",
}
`);
});

it('returns info with "sdkVersion" and "channel"', () => {
expect(
parseRuntimeUrl(
'exp://u.expo.dev/xxx?runtime-version=exposdk:69.0.0&snack-channel=channelid',
),
).toMatchInlineSnapshot(`
Object {
"channel": "channelid",
"sdkVersion": "69.0.0",
"snack": undefined,
}
`);
});

it('returns info with "sdkVersion", "snack", and "channel"', () => {
expect(
parseRuntimeUrl(
'exp://u.expo.dev/xxx?runtime-version=exposdk:69.0.0&snack=snackid&snack-channel=channelid',
),
).toMatchInlineSnapshot(`
Object {
"channel": "channelid",
"sdkVersion": "69.0.0",
"snack": "snackid",
}
`);
});
});
});
14 changes: 2 additions & 12 deletions packages/snack-content/src/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,8 @@ export function createRuntimeUrl(options: RuntimeUrlInfo & RuntimeUrlOptions): s
const endpoint = options.endpoint || SNACK_RUNTIME_URL_ENDPOINT;
const parameters = new URLSearchParams();

// Add the EAS Update runtime version, based on SDK version support.
// Up until SDK 50, it should use `exposdk:xx.0.0` format.
// Starting from SDK 51, it should use `xx.0.0` format.
// TODO(cedric): check if we can remove the `exposdk:` prefix for SDK 50 and below.
const majorVersion = options.sdkVersion.split('.')[0] || null;
if (majorVersion && parseInt(majorVersion, 10) >= 51) {
parameters.set('runtime-version', options.sdkVersion);
} else {
parameters.set('runtime-version', `exposdk:${options.sdkVersion}`);
}

// Add the other EAS Update references, `platform` is added by Expo Go
// Add the EAS Update references, `platform` is added by Expo Go
parameters.set('runtime-version', `exposdk:${options.sdkVersion}`);
parameters.set('channel-name', 'production');

// Add the Snack references
Expand Down
4 changes: 2 additions & 2 deletions packages/snack-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snack-sdk",
"version": "5.1.0",
"version": "5.0.0",
"description": "The Expo Snack SDK",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down Expand Up @@ -71,7 +71,7 @@
"nullthrows": "^1.1.1",
"pubnub": "^7.2.0",
"semver": "^7.3.4",
"snack-content": "^2.1.0",
"snack-content": "^2.0.0",
"socket.io-client": "~4.5.4",
"ua-parser-js": "^0.7.22",
"validate-npm-package-name": "^3.0.0"
Expand Down
6 changes: 0 additions & 6 deletions runtime/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ const { major } = require('semver');
* @returns {import('expo/config').ExpoConfig}
*/
module.exports = ({ config }) => {
// Set app version to major Expo SDK version.
// This is used for EAS Updates to launch the correct bundle.
config.version = `${major(expoVersion)}.0.0`;
config.runtimeVersion ||= {};
config.runtimeVersion.policy = 'appVersion';

// Set web export prefix major Expo SDK version.
// This is used to properly host the web build on Snack's S3 hosting.
config.experiments ||= {};
Expand Down
5 changes: 4 additions & 1 deletion runtime/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
"favicon": "./assets/favicon.png",
"bundler": "metro"
},
"plugins": ["expo-font", "expo-router", "expo-asset"]
"plugins": ["expo-font", "expo-router", "expo-asset"],
"runtimeVersion": {
"policy": "sdkVersion"
}
}
39 changes: 36 additions & 3 deletions runtime/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2864,6 +2864,11 @@ ansi-styles@^5.0.0:
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b"
integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==

any-promise@^1.0.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==

anymatch@^3.0.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e"
Expand Down Expand Up @@ -3669,6 +3674,11 @@ commander@^2.20.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

commander@^4.0.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068"
integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==

commander@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
Expand Down Expand Up @@ -7269,6 +7279,15 @@ mv@~2:
ncp "~2.0.0"
rimraf "~2.4.0"

mz@^2.7.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32"
integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==
dependencies:
any-promise "^1.0.0"
object-assign "^4.0.1"
thenify-all "^1.0.0"

nanoid@^3.1.23, nanoid@^3.3.7:
version "3.3.7"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8"
Expand Down Expand Up @@ -7397,7 +7416,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/ob1/-/ob1-0.80.4.tgz#a2e77e2dbe144c76356c834b994e147e19bb472f"
integrity sha512-Lku8OBpq+fhF1ZdKUjbPnTNeqG+3OL0psGAEVJ8zcUiCB5/DPGR/rm3kLcjKDylzC9Rfv540/7I08+oImzfrhw==

object-assign@^4.1.0, object-assign@^4.1.1:
object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==
Expand Down Expand Up @@ -7806,7 +7825,7 @@ pify@^4.0.1:
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==

pirates@^4.0.4, pirates@^4.0.6:
pirates@^4.0.1, pirates@^4.0.4, pirates@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.6.tgz#3018ae32ecfcff6c29ba2267cbf21166ac1f36b9"
integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==
Expand Down Expand Up @@ -8833,7 +8852,7 @@ smart-buffer@^4.2.0:
version "4.0.0"

"snack-content@file:../packages/snack-content":
version "2.0.0"
version "2.1.0"
dependencies:
semver "^7.3.4"

Expand Down Expand Up @@ -9334,6 +9353,20 @@ text-table@^0.2.0:
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==

thenify-all@^1.0.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726"
integrity sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==
dependencies:
thenify ">= 3.1.0 < 4"

"thenify@>= 3.1.0 < 4":
version "3.3.1"
resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f"
integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==
dependencies:
any-promise "^1.0.0"

throat@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b"
Expand Down
4 changes: 2 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
"redux": "^4.0.1",
"sanitize-html": "^1.20.0",
"snack-babel-standalone": "^3.0.1",
"snack-content": "^2.1.0",
"snack-content": "^2.0.0",
"snack-eslint-standalone": "^2.0.0",
"snack-sdk": "^5.1.0",
"snack-sdk": "^5.0.0",
"validate-npm-package-name": "^3.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit 85abf50

Please sign in to comment.