mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-19 08:36:15 +00:00
Merge pull request #1850 from balena-io/1770-nogitignore-feature-switch
v12 preparations: Add feature switch for '--nogitignore'
This commit is contained in:
commit
fd7e7f57eb
@ -26,6 +26,7 @@ import {
|
||||
validateDotLocalUrl,
|
||||
validateIPAddress,
|
||||
} from '../utils/validation';
|
||||
import { isV12 } from '../utils/version';
|
||||
|
||||
enum BuildTarget {
|
||||
Cloud,
|
||||
@ -265,7 +266,9 @@ export const push: CommandDefinition<
|
||||
{
|
||||
signature: 'nogitignore',
|
||||
alias: 'G',
|
||||
description: stripIndent`
|
||||
description: isV12()
|
||||
? 'No-op and deprecated since balena CLI v12.0.0. See "balena help push".'
|
||||
: stripIndent`
|
||||
Disregard all .gitignore files, and consider only the .dockerignore file (if any)
|
||||
at the source directory. This will be the default behavior in an upcoming major
|
||||
version release. For more information, see 'balena help push'.
|
||||
@ -303,6 +306,8 @@ export const push: CommandDefinition<
|
||||
},
|
||||
);
|
||||
|
||||
const nogitignore = !!options.nogitignore || isV12();
|
||||
|
||||
const buildTarget = getBuildTarget(appOrDevice);
|
||||
switch (buildTarget) {
|
||||
case BuildTarget.Cloud:
|
||||
@ -349,7 +354,7 @@ export const push: CommandDefinition<
|
||||
source,
|
||||
auth: token,
|
||||
baseUrl,
|
||||
nogitignore: !!options.nogitignore,
|
||||
nogitignore,
|
||||
sdk,
|
||||
opts,
|
||||
};
|
||||
@ -373,7 +378,7 @@ export const push: CommandDefinition<
|
||||
dockerfilePath,
|
||||
registrySecrets,
|
||||
nocache: options.nocache || false,
|
||||
nogitignore: options.nogitignore || false,
|
||||
nogitignore,
|
||||
noParentCheck: options['noparent-check'] || false,
|
||||
nolive: options.nolive || false,
|
||||
detached: options.detached || false,
|
||||
|
@ -34,6 +34,7 @@ export const appendProjectOptions = opts =>
|
||||
|
||||
export function appendOptions(opts) {
|
||||
const Logger = require('./logger');
|
||||
const { isV12 } = require('./version');
|
||||
return appendProjectOptions(opts).concat([
|
||||
{
|
||||
signature: 'emulated',
|
||||
@ -54,7 +55,9 @@ export function appendOptions(opts) {
|
||||
},
|
||||
{
|
||||
signature: 'nogitignore',
|
||||
description: stripIndent`
|
||||
description: isV12()
|
||||
? `No-op and deprecated since balena CLI v12.0.0. See "balena help ${Logger.command}".`
|
||||
: stripIndent`
|
||||
Disregard all .gitignore files, and consider only the .dockerignore file (if any)
|
||||
at the source directory. This will be the default behavior in an upcoming major
|
||||
version release. For more information, see 'balena help ${Logger.command}'.
|
||||
@ -91,12 +94,13 @@ Source files are not modified.`,
|
||||
*/
|
||||
export function generateOpts(options) {
|
||||
const fs = require('mz/fs');
|
||||
const { isV12 } = require('./version');
|
||||
return fs.realpath(options.source || '.').then(projectPath => ({
|
||||
projectName: options.projectName,
|
||||
projectPath,
|
||||
inlineLogs: !!options.logs,
|
||||
dockerfilePath: options.dockerfile,
|
||||
nogitignore: !!options.nogitignore,
|
||||
nogitignore: !!options.nogitignore || isV12(),
|
||||
noParentCheck: options['noparent-check'],
|
||||
}));
|
||||
}
|
||||
|
@ -25,9 +25,6 @@ import * as ShellEscape from 'shell-escape';
|
||||
import { ExpectedError } from '../errors';
|
||||
import { getBalenaSdk, getChalk, getVisuals } from './lazy';
|
||||
|
||||
import * as semver from 'semver';
|
||||
import { version } from '../../package.json';
|
||||
|
||||
export function getGroupDefaults(group: {
|
||||
options: Array<{ name: string; default?: string }>;
|
||||
}): { [name: string]: string | number | undefined } {
|
||||
@ -468,7 +465,3 @@ export function getProxyConfig(): ProxyConfig | undefined {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function isVersionGTE(v: string) {
|
||||
return semver.gte(process.env.BALENA_CLI_VERSION_OVERRIDE || version, v);
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { isV12 } from './version';
|
||||
|
||||
const DEBUG_MODE = !!process.env.DEBUG;
|
||||
|
||||
export const reachingOut = `\
|
||||
@ -67,7 +69,7 @@ If the --registry-secrets option is not specified, and a secrets.yml or
|
||||
secrets.json file exists in the balena directory (usually $HOME/.balena),
|
||||
this file will be used instead.`;
|
||||
|
||||
export const dockerignoreHelp = `\
|
||||
const dockerignoreHelpV11 = `\
|
||||
DOCKERIGNORE AND GITIGNORE FILES
|
||||
By default, both '.dockerignore' and '.gitignore' files are taken into account
|
||||
in order to prevent files from being sent to the balenaCloud builder or Docker
|
||||
@ -102,3 +104,21 @@ If necessary, the effect of the '**/.git' pattern may be modified by adding
|
||||
For documentation on pattern format, see:
|
||||
- https://docs.docker.com/engine/reference/builder/#dockerignore-file
|
||||
- https://www.npmjs.com/package/@balena/dockerignore`;
|
||||
|
||||
const dockerignoreHelpV12 =
|
||||
`DOCKERIGNORE AND GITIGNORE FILES
|
||||
The balena CLI will use a '.dockerignore' file (if any) at the source directory
|
||||
in order to decide which source files to exclude from the "build context" sent
|
||||
to balenaCloud, Docker or balenaEngine. Previous balena CLI releases (before
|
||||
v12.0.0) also took '.gitignore' files into account, but this is no longer the
|
||||
case. This allows files to be used for an image build even if they are listed
|
||||
in '.gitignore'.
|
||||
|
||||
A few "hardcoded" dockerignore patterns are also used and "merged" (in memory)
|
||||
with the patterns found in the '.dockerignore' file (if any), in the following
|
||||
order:
|
||||
` + dockerignoreHelpV11.substring(dockerignoreHelpV11.indexOf('\n **/.git'));
|
||||
|
||||
export const dockerignoreHelp = isV12()
|
||||
? dockerignoreHelpV12
|
||||
: dockerignoreHelpV11;
|
||||
|
@ -21,9 +21,9 @@ import _ = require('lodash');
|
||||
import _form = require('resin-cli-form');
|
||||
|
||||
import { exitWithExpectedError, instanceOf, NotLoggedInError } from '../errors';
|
||||
import { isVersionGTE } from './helpers';
|
||||
import { getBalenaSdk, getVisuals } from './lazy';
|
||||
import validation = require('./validation');
|
||||
import { isV12 } from './version';
|
||||
|
||||
const getForm = _.once((): typeof _form => require('resin-cli-form'));
|
||||
|
||||
@ -81,7 +81,7 @@ export function authenticate(options: {}): Bluebird<void> {
|
||||
export async function checkLoggedIn(): Promise<void> {
|
||||
const balena = getBalenaSdk();
|
||||
if (!(await balena.auth.isLoggedIn())) {
|
||||
if (isVersionGTE('12.0.0')) {
|
||||
if (isV12()) {
|
||||
throw new NotLoggedInError(stripIndent`
|
||||
Login required: use the “balena login” command to log in.
|
||||
`);
|
||||
|
32
lib/utils/version.ts
Normal file
32
lib/utils/version.ts
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018-2020 Balena Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import * as semver from 'semver';
|
||||
import { version } from '../../package.json';
|
||||
|
||||
export function isVersionGTE(v: string): boolean {
|
||||
return semver.gte(process.env.BALENA_CLI_VERSION_OVERRIDE || version, v);
|
||||
}
|
||||
|
||||
let v12: boolean;
|
||||
|
||||
export function isV12(): boolean {
|
||||
if (v12 === undefined) {
|
||||
v12 = isVersionGTE('12.0.0');
|
||||
}
|
||||
return v12;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user