Skip to content
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

refactor(build): Add ability to build angularjs with Docker #1

Open
wants to merge 3 commits into
base: 1.8.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
tmp
.circleci

build
20 changes: 20 additions & 0 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ artifacts.
* `docs/` — A directory that contains a standalone version of the docs
(same as served in `docs.angularjs.org`).


#### Docker Based Build

To build AngularJS using docker, same process as regular build but can run:

```shell
# Clone your Github repository:
git clone https://github.com/<github username>/angular.js.git

# Go to the AngularJS directory:
cd angular.js

# Run docker (>= v23) build
docker build --target artifact --output type=local,dest=. .

# Run docker (< v23) build
# DOCKER_BUILDKIT=1 docker build --target artifact --output type=local,dest=. .
```


### <a name="local-server"></a> Running a Local Development Web Server

To debug code, run end-to-end tests, and serve the docs, it is often useful to have a local
Expand Down
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:12.22.12-alpine AS base
ARG NEXT_TAG_VERSION v1.x.x
ARG NG1_BUILD_NO_REMOTE_VERSION_REQUESTS 1

FROM base AS deps
WORKDIR /app
RUN apk add --no-cache libc6-compat
COPY package.json yarn.lock* ./
RUN yarn config set registry https://registry.npmjs.org/
RUN yarn --frozen-lockfile

FROM base AS builder
WORKDIR /app
RUN apk add curl git openjdk11
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV CI=1
ENV NODE_ENV=production
ENV NEXT_TAG_VERSION=${NEXT_TAG_VERSION}
ENV NG1_BUILD_NO_REMOTE_VERSION_REQUESTS=${NG1_BUILD_NO_REMOTE_VERSION_REQUESTS}
RUN yarn grunt package

FROM scratch AS artifact
COPY --from=builder /app/build /build
20 changes: 19 additions & 1 deletion lib/versions/version-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var process = require('process');
// We are only interested in whether this environment variable exists, hence the !!
var NO_REMOTE_REQUESTS = !!process.env['NG1_BUILD_NO_REMOTE_VERSION_REQUESTS'];
var versionSource = NO_REMOTE_REQUESTS ? 'local' : 'remote';
var ENV_VERSION = process.env['NEXT_TAG_VERSION'];

var currentPackage, previousVersions, cdnVersion;

Expand Down Expand Up @@ -215,12 +216,29 @@ var getSnapshotVersion = function() {
return version;
};

/**
* Get the version from env variable in semver format
* @return {SemVer} The env variable
*/
var getPredefinedVersion = function() {
var version = semver.parse(ENV_VERSION);

if (version && checkBranchPattern(version.version, currentPackage.branchPattern)) {
version.codeName = '';
version.full = version.version;
version.branch = 'v' + currentPackage.branchPattern.replace('*', 'x');
return version;
}

return null;
};


exports.currentPackage = currentPackage = getPackage();
exports.gitRepoInfo = getGitRepoInfo();
exports.previousVersions = previousVersions = getPreviousVersions();
exports.cdnVersion = cdnVersion = getCdnVersion();
exports.currentVersion = getTaggedVersion() || getSnapshotVersion();
exports.currentVersion = getPredefinedVersion() || getTaggedVersion() || getSnapshotVersion();

if (NO_REMOTE_REQUESTS) {
console.log('==============================================================================================');
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "angular",
"license": "MIT",
"branchVersion": "^1.8.0",
"branchPattern": "1.8.*",
"branchPattern": "1.9.*",
"version": "1.9.4",
"distTag": "latest",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ function copy(source, destination, maxDepth) {
return new source.constructor(source.valueOf());

case '[object RegExp]':
var re = new RegExp(source.source, source.toString().match(/[^/]*$/)[0]);
var re = new RegExp(source.source, source.toString().match(/\/([^/]*)$/)[1]);
re.lastIndex = source.lastIndex;
return re;

Expand Down
24 changes: 17 additions & 7 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
// first check if there are spaces because it's not the same pattern
var trimmedSrcset = trim(value);
// ( 999x ,| 999w ,| ,|, )
var srcPattern = /(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/;
var srcPattern = /(\s+(?:\d+(?:x\s*|w\s*))?,\s*|,\s+)/;
var pattern = /\s/.test(trimmedSrcset) ? srcPattern : /(,)/;

// split srcset into tuple of uri and descriptor except for the last item
Expand Down Expand Up @@ -2647,7 +2647,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
sibling.parentNode.removeChild(sibling);
}
if (notLiveList && sibling === nodeList[idx + 1]) {
nodeList.splice(idx + 1, 1);
splice.call(nodeList, idx + 1, 1);
}
}
}
Expand Down Expand Up @@ -2794,7 +2794,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
break;
case NODE_TYPE_TEXT: /* Text Node */
addTextInterpolateDirective(directives, node.nodeValue);
// Don't interpolate `<textarea>` contents in IE due to security considerations.
if (!msie || !node.parentNode || nodeName_(node.parentNode) !== 'textarea') {
addTextInterpolateDirective(directives, node.nodeValue);
}
break;
case NODE_TYPE_COMMENT: /* Comment */
if (!commentDirectivesEnabled) break;
Expand Down Expand Up @@ -3302,11 +3305,18 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
var controller = elementControllers[name];
var bindings = controllerDirective.$$bindings.bindToController;

controller.instance = controller();
$element.data('$' + controllerDirective.name + 'Controller', controller.instance);
controller.bindingInfo =
initializeDirectiveBindings(controllerScope, attrs, controller.instance, bindings, controllerDirective);
var customBindingAssignment = isFunction(compile.$$customAssignBindings) &&
compile.$$customAssignBindings(
bindings, controller, controllerDirective, controllerScope, $element, attrs,
initializeDirectiveBindings);

if (!customBindingAssignment) {
controller.instance = controller();
$element.data('$' + controllerDirective.name + 'Controller', controller.instance);
controller.bindingInfo =
initializeDirectiveBindings(controllerScope, attrs, controller.instance, bindings, controllerDirective);
}
}

// Bind the required controllers to the controller, if `require` is an object and `bindToController` is truthy
forEach(controllerDirectives, function(controllerDirective, name) {
Expand Down
2 changes: 1 addition & 1 deletion src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var ISO_DATE_REGEXP = /^\d{4,}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+(?:[+-
// 8. Query
// 9. Fragment
// 1111111111111111 222 333333 44444 55555555555555555555555 666 77777777 8888888 999
var URL_REGEXP = /^[a-z][a-z\d.+-]*:\/*(?:[^:@]+(?::[^@]+)?@)?(?:[^\s:/?#]+|\[[a-f\d:]+])(?::\d+)?(?:\/[^?#]*)?(?:\?[^#]*)?(?:#.*)?$/i;
var URL_REGEXP = /^[a-z][a-z\d.+-]*:\/*(?:[^:@/]*(?::[^@]+)?@)?(?:[^\s:/?#]+|\[[a-f\d:]+])(?::\d+)?(?:\/[^?#]*)?(?:\?[^#]*)?(?:#.*)?$/i;
// eslint-disable-next-line max-len
var EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
var NUMBER_REGEXP = /^\s*(-|\+)?(\d+|(\d*(\.\d*)))([eE][+-]?\d+)?\s*$/;
Expand Down
26 changes: 19 additions & 7 deletions src/ng/filter/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ currencyFilter.$inject = ['$locale'];
function currencyFilter($locale) {
var formats = $locale.NUMBER_FORMATS;
return function(amount, currencySymbol, fractionSize) {

// if null or undefined pass it through
if (amount == null) {
return amount;
}

if (isUndefined(currencySymbol)) {
currencySymbol = formats.CURRENCY_SYM;
}
Expand All @@ -68,14 +74,20 @@ function currencyFilter($locale) {
fractionSize = formats.PATTERNS[1].maxFrac;
}

// If the currency symbol is empty, trim whitespace around the symbol
var currencySymbolRe = !currencySymbol ? /\s*\u00A4\s*/g : /\u00A4/g;
var value = formatNumber(
amount,
formats.PATTERNS[1],
formats.GROUP_SEP,
formats.DECIMAL_SEP,
fractionSize
);

// if null or undefined pass it through
return (amount == null)
? amount
: formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, fractionSize).
replace(currencySymbolRe, currencySymbol);
// If the currency symbol is empty, trim whitespace around the symbol
return currencySymbol ?
value.replace(/\u00A4/g, currencySymbol) :
value.replace(/(^|\S)\s*\u00A4\s*(\S|$)/g, function(_, g1, g2) {
return g1 + currencySymbol + g2;
});
};
}

Expand Down
3 changes: 0 additions & 3 deletions src/ngAnimate/animateCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,6 @@ var $AnimateCssProvider = ['$animateProvider', /** @this */ function($animatePro

if (!timings) {
timings = computeCssStyles($window, node, properties);
if (timings.animationIterationCount === 'infinite') {
timings.animationIterationCount = 1;
}
}

// if a css animation has no duration we
Expand Down
2 changes: 1 addition & 1 deletion src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ function assertArgDefined(args, index, name) {
}

function stripQueryAndHash(url) {
return url.replace(/[?#].*$/, '');
return url.replace(/^([^?#]*)[?#].*$/, '$1');
}

function MockHttpExpectation(expectedMethod, expectedUrl, expectedData, expectedHeaders,
Expand Down
38 changes: 35 additions & 3 deletions src/ngMock/browserTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,41 @@
);
}

} else {
} else if (/^focus(?:in|out)?$|^blur$/.test(eventType)) {
try {
evnt = new window.FocusEvent(eventType, {
bubbles: eventData.bubbles,
cancelable: eventData.cancelable,
relatedTarget: relatedTarget
});
} catch (e) {
// Support: IE9-11+
// We should use `FocusEvent` here, but there's no legacy initialization method
// allowing to set `relatedTarget` and if we create a `FocusEvent`, `relatedTarget`
// becomes read-only. Therefore, use the generic `Events` and set the property
// manually.
evnt = window.document.createEvent('Events');
evnt.initEvent(eventType, eventData.bubbles, eventData.cancelable);
evnt.relatedTarget = relatedTarget;
}

// Support: IE 9-11 only
// jQuery >=3.7.0 simulates `focus` in IE via `focusin` and `blur` via `focusout`
// as `focus` & `blur` are asynchronous in IE and `focusin`/`focusout` -
// synchronous. All those events are synchronous in other browsers. This
// simulation makes some tests fail if they dispatch `focus` without dispatching
// `focusin` or `blur` without `focusout`. To simulate native IE behavior better,
// trigger the bubbling surrogate earlier. (Note that in all modern browsers
// the bubbling surrogates are fired after the non-bubbling ones which is
// a spec violation)
if (eventType === 'focus' && window.document.documentMode) {
browserTrigger(element, 'focusin', eventData);
}
if (eventType === 'blur' && window.document.documentMode) {
browserTrigger(element, 'focusout', eventData);
}

} else {
evnt = window.document.createEvent('MouseEvents');
x = x || 0;
y = y || 0;
Expand All @@ -166,8 +200,6 @@
* read */
evnt.$manualTimeStamp = eventData.timeStamp;

if (!evnt) return;

if (!eventData.bubbles || supportsEventBubblingInDetachedTree() || isAttachedToDocument(element)) {
return element.dispatchEvent(evnt);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/ngResource/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ angular.module('ngResource', ['ng']).

// strip trailing slashes and set the url (unless this behavior is specifically disabled)
if (self.defaults.stripTrailingSlashes) {
url = url.replace(/\/+$/, '') || '/';
url = url.replace(/(?<=\w)\/+$/, '') || '/';
}

// Collapse `/.` if found in the last URL path segment before the query.
Expand Down