@google/clasp
Version:
Develop Apps Script Projects locally
50 lines (49 loc) • 2.21 kB
JavaScript
// Copyright 2025 Google LLC
//
// 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
//
// https://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.
// This file defines the 'show-file-status' (alias 'status') command for the
// clasp CLI.
import { Command } from 'commander';
import { intl } from '../intl.js';
import { withSpinner } from './utils.js';
export const command = new Command('show-file-status')
.alias('status')
.description('Lists files that will be pushed by clasp')
.action(async function () {
var _a;
const options = this.optsWithGlobals();
const clasp = this.opts().clasp;
const outputAsJson = (_a = options === null || options === void 0 ? void 0 : options.json) !== null && _a !== void 0 ? _a : false;
const spinnerMsg = intl.formatMessage({ id: "3pOneN", defaultMessage: [{ type: 0, value: "Analyzing project files..." }] });
const [filesToPush, untrackedFiles] = await withSpinner(spinnerMsg, async () => {
return await Promise.all([clasp.files.collectLocalFiles(), clasp.files.getUntrackedFiles()]);
});
if (outputAsJson) {
const json = JSON.stringify({
filesToPush: filesToPush.map(f => f.localPath),
untrackedFiles,
});
console.log(json);
return;
}
const trackedMsg = intl.formatMessage({ id: "eSUzih", defaultMessage: [{ type: 0, value: "Tracked files:" }] });
console.log(trackedMsg);
for (const file of filesToPush) {
console.log(`└─ ${file.localPath}`);
}
const untrackedMsg = intl.formatMessage({ id: "G6KFcG", defaultMessage: [{ type: 0, value: "Untracked files:" }] });
console.log(untrackedMsg);
for (const file of untrackedFiles) {
console.log(`└─ ${file}`);
}
});