forked from emberjs/data
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit: 1. Allows one to rollback belongsTo and hasMany relationships. 2. Added 'shouldRemoveDeletedFromRelationshipsPriorToSave' flag to Adapter that allows one to opt back into the old deleted record from many array behavior (pre emberjs#3539). 3. Adds bin/build.js to build a standalone version of ember-data. Known issues: 1. Rolling back a hasMany relationship from the parent side of that relationship does not work (doing the same from the child side works fine). See test that is commented out below as well as the discussion at the end of emberjs#2881#issuecomment-204634262 This was previously emberjs#2881 and is related to emberjs#3698
- Loading branch information
1 parent
cd70bee
commit 721e8a1
Showing
35 changed files
with
2,408 additions
and
96 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -61,3 +61,4 @@ benchmarks/results/*.json | |
.vscode/ | ||
.idea/ | ||
*.iml | ||
packed |
This file contains 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,113 @@ | ||
# Package Ember Data for Local Use | ||
|
||
## Overview | ||
|
||
Ember Data uses `pnpm` but our projects use `npm`. In order to develop against | ||
Ember Data locally (i.e. so we get proper code completion, navigation, etc...) we | ||
need to do a few things first: | ||
|
||
1) [Environment](#environment) | ||
2) [Build Ember Data Packages](#build-ember-data-packages) | ||
3) [Link Ember Data into a Project](#link-ember-data-into-a-project) | ||
|
||
## Environment | ||
|
||
Make sure pnpm is available and configure our environment: | ||
|
||
```sh | ||
PROJECTS="$HOME/Source/IdeaProjects" | ||
PROJECT="$PROJECTS/MP Foods Inc" | ||
EMBER_DATA="$PROJECTS/Ember/ember-data" | ||
EMBER_DATA_VERSION="4.8.8" | ||
PACKAGES="-ember-data:adapter:canary-features:debug:model:private-build-infra:record-data:serializer:store:tracking" | ||
|
||
# Setup array of packages | ||
OLD_IFS="$IFS" | ||
IFS=: | ||
set -- $PACKAGES | ||
IFS="$OLD_IFS" | ||
unset OLD_IFS | ||
|
||
# Ensure a sane development environment | ||
cd "$EMBER_DATA" || return 1 | ||
corepack enable | ||
corepack prepare "$(jq -r '.packageManager | @text' package.json)" --activate | ||
pnpm install | ||
``` | ||
|
||
## Build Ember Data Packages | ||
|
||
Generate the local packages that comprise Ember Data: | ||
|
||
```sh | ||
cd "$EMBER_DATA" || return 1 | ||
rm -rf "$EMBER_DATA/packed" | ||
mkdir "$EMBER_DATA/packed" | ||
printf "Copy the following into your project's package.json:\n\n" | ||
for pkg; do ( | ||
set -e | ||
cd "$EMBER_DATA/packages/$pkg" | ||
if [ "$pkg" = -ember-data ]; then | ||
pkgName="${pkg#-}-$EMBER_DATA_VERSION" | ||
else | ||
pkgName="ember-data-$pkg-$EMBER_DATA_VERSION" | ||
fi | ||
pnpm pack --pack-destination="$EMBER_DATA/packed" >/dev/null 2>&1 | ||
cd "$EMBER_DATA/packed" | ||
tar -s "/^package/$pkgName/" -xf "$pkgName.tgz" | ||
rm "$pkgName.tgz" | ||
sed -E -i '' "/\"dependencies\": {/,/}/s|\"@ember-data/([-a-z]*)\": .*|\"@ember-data/\1\": \"file:$EMBER_DATA/packed/ember-data-\1-$EMBER_DATA_VERSION\",|" "$pkgName/package.json" | ||
if [ "$pkg" = -ember-data ]; then | ||
printf '"ember-data": "file:%s/packed/%s",\n' "$EMBER_DATA" "$pkgName" | ||
else | ||
printf '"@ember-data/%s": "file:%s/packed/%s",\n' "$pkg" "$EMBER_DATA" "$pkgName" | ||
fi | ||
) || return 1; done | ||
unset pkg pkgName | ||
``` | ||
|
||
## Link Ember Data into a Project | ||
|
||
```sh | ||
cd "$PROJECT" | ||
|
||
# Optionally, ensure npm installs links for local dependencies instead of copying (i.e. 'installing') them. The name of | ||
# this is confusing. `npm config set install-links true` or `npm install --install-links` means npm will actually install | ||
# (i.e. copy) local dependencies into node_modules instead of just linking to them. If `install-links` is `true` then | ||
# you must re-run `npm install` *everytime* you (re)generate the packages in the previous step above. | ||
npm config set install-links false | ||
|
||
# *HOWEVER*, npm install from sb-pkg just doesn't handle symlinks correctly and I have not found a work around (`npm | ||
# --preserve-symlinks` and the like doesn't seem to help, so for now, stick to `install-links true`. | ||
npm config set install-links true | ||
|
||
# Use `npm` to install dependencies to the generated packages, *or* copy the output from the section above and paste | ||
# into the relevant dependencies section of the project's package.json (i.e. `dependencies` or `devDependencies`). | ||
for pkg; do | ||
if [ "$pkg" = '-ember-data' ]; then | ||
npm install --save-dev "$EMBER_DATA/packed/${pkg#-}-$EMBER_DATA_VERSION" | ||
else | ||
npm install --save-dev "$EMBER_DATA/packed/ember-data-$pkg-$EMBER_DATA_VERSION" | ||
fi | ||
done | ||
# Finally, for posterity, (re)run: | ||
npm install | ||
``` | ||
|
||
Reference: | ||
|
||
- https://docs.npmjs.com/cli/v9/commands/npm-link | ||
|
||
#### Build the Ember Data Addon using Swarmbox Web Package | ||
|
||
```sh | ||
# Build ember-data addon... | ||
cd "$PROJECT"/swarmbox-web-framework | ||
# This is important after making any changes above to make sure we install the new version of ember-data built above | ||
# (node doesn't re-install these when using install-links=true)... | ||
dash -e ./setup.sh | ||
cd "$PROJECT"/swarmbox-web-framework/modules/swarmbox-web-data | ||
node "$PROJECTS/SwarmBox WebPackage/swarmbox-web-package/lib/cli.js" -e production addons | ||
# ...generated addons will be in public/vendor/ember-addons-new | ||
cp -av public/vendor/ember-addons-new/ember-data.* public/vendor/ember-addons/ | ||
``` |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.