Home / File/ validate-tags.js — react Source File

validate-tags.js — react Source File

Architecture documentation for validate-tags.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

#!/usr/bin/env node

'use strict';

const {readJson} = require('fs-extra');
const {join} = require('path');
const theme = require('../theme');

const run = async ({cwd, packages, tags}) => {
  // Prevent a "next" release from ever being published as @latest
  // All canaries share a version number, so it's okay to check any of them.
  const arbitraryPackageName = packages[0];
  const packageJSONPath = join(
    cwd,
    'build',
    'node_modules',
    arbitraryPackageName,
    'package.json'
  );
  const {version} = await readJson(packageJSONPath);
  const isExperimentalVersion = version.indexOf('experimental') !== -1;
  if (version.indexOf('-') !== -1) {
    if (tags.includes('latest')) {
      if (isExperimentalVersion) {
        console.log(
          theme`{error Experimental release} {version ${version}} {error cannot be tagged as} {tag latest}`
        );
      } else {
        console.log(
          theme`{error Next release} {version ${version}} {error cannot be tagged as} {tag latest}`
        );
      }
      process.exit(1);
    }
    if (tags.includes('next') && isExperimentalVersion) {
      console.log(
        theme`{error Experimental release} {version ${version}} {error cannot be tagged as} {tag next}`
      );
      process.exit(1);
    }
    if (tags.includes('experimental') && !isExperimentalVersion) {
      console.log(
        theme`{error Next release} {version ${version}} {error cannot be tagged as} {tag experimental}`
      );
      process.exit(1);
    }
  } else {
    if (!tags.includes('latest')) {
      console.log(
        theme`{error Stable release} {version ${version}} {error must always be tagged as} {tag latest}`
      );
      process.exit(1);
    }
    if (tags.includes('experimental')) {
      console.log(
        theme`{error Stable release} {version ${version}} {error cannot be tagged as} {tag experimental}`
      );
      process.exit(1);
    }
  }
};

module.exports = run;

Domain

Subdomains

Functions

Frequently Asked Questions

What does validate-tags.js do?
validate-tags.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in validate-tags.js?
validate-tags.js defines 1 function(s): run.
Where is validate-tags.js in the architecture?
validate-tags.js is located at scripts/release/publish-commands/validate-tags.js (domain: BabelCompiler, subdomain: Optimization, directory: scripts/release/publish-commands).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free